db-rest/.github/workflows/docker-image.yml

76 lines
2.5 KiB
YAML
Raw Normal View History

2021-09-13 18:14:49 +02:00
name: build & publish Docker image
on:
push:
branches:
2022-12-19 13:18:25 +01:00
- 6
2021-09-13 18:14:49 +02:00
jobs:
2022-04-03 13:44:22 +02:00
lint-test:
2023-03-25 16:58:34 +01:00
name: lint, build & test
2022-04-03 13:44:22 +02:00
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
2022-04-03 13:44:22 +02:00
- name: setup Node
uses: actions/setup-node@v3
2022-04-03 13:44:22 +02:00
with:
2022-12-19 13:20:17 +01:00
node-version: 18.x
- run: npm ci
2022-04-03 14:15:36 +02:00
- run: npm run lint
2023-03-25 16:58:34 +01:00
- run: npm run build
2022-04-03 13:44:22 +02:00
- run: npm test
2021-09-13 18:14:49 +02:00
build-and-publish:
name: build & publish Docker image
2022-04-03 13:44:22 +02:00
needs: [lint-test]
2021-09-13 18:14:49 +02:00
runs-on: ubuntu-latest
steps:
- name: check out the repo
uses: actions/checkout@v3
- name: set up QEMU
uses: docker/setup-qemu-action@v3
- name: configure Docker to use buildx
uses: docker/setup-buildx-action@v2
2021-09-13 18:14:49 +02:00
- name: log in to Docker Hub
uses: docker/login-action@v2
2021-09-13 18:14:49 +02:00
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
- name: build Docker image & push to Docker Hub
uses: docker/build-push-action@v4
2021-09-13 18:14:49 +02:00
with:
2023-03-26 18:33:48 +02:00
context: .
2021-09-13 18:14:49 +02:00
push: true
platforms: linux/amd64,linux/arm64
2021-09-13 18:14:49 +02:00
tags: |
2022-12-19 13:18:25 +01:00
derhuerst/db-rest:6
2021-09-13 18:14:49 +02:00
derhuerst/db-rest:latest
# https://docs.docker.com/build/ci/github-actions/examples/#github-cache
cache-from: type=gha
cache-to: type=gha,mode=max,oci-mediatypes=true,compression=zstd
# this is for the public-transport/infrastructure cluster
- name: log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: determine commit hash
id: hash
run: echo "::set-output name=hash::$(echo $GITHUB_SHA | head -c7)"
- name: determine current date and time
id: datetime
run: echo "::set-output name=datetime::$(date -u +'%Y-%m-%dT%H.%M.%SZ')"
- name: push Docker image to GitHub Registry
uses: docker/build-push-action@v4
with:
2023-03-26 18:33:48 +02:00
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/${{github.repository}}:v6
ghcr.io/${{github.repository}}:v6_${{steps.hash.outputs.hash}}_${{steps.datetime.outputs.datetime}}
# https://docs.docker.com/build/ci/github-actions/examples/#github-cache
cache-from: type=gha
cache-to: type=gha,mode=max,oci-mediatypes=true,compression=zstd