From 00240fa1b0b9bff6b5bcf64db52f29f7292279d9 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Mon, 6 May 2024 10:19:12 +0200 Subject: [PATCH] add docker build workflow --- .../workflows/build-production-container.yml | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/build-production-container.yml diff --git a/.github/workflows/build-production-container.yml b/.github/workflows/build-production-container.yml new file mode 100644 index 0000000..54caab7 --- /dev/null +++ b/.github/workflows/build-production-container.yml @@ -0,0 +1,57 @@ +--- +name: Build deployment container +on: + push: + branches: + - master + pull_request: + branches: + - master + workflow_dispatch: +jobs: + docker: + runs-on: ubuntu-22.04 + name: Docker Push + steps: + - uses: actions/checkout@v4 + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_HUB_USER }} + password: ${{ secrets.DOCKER_HUB_TOKEN }} + - name: Build test image + uses: docker/build-push-action@v5 + with: + tags: ${{ github.repository }}:test + target: test + push: false + - name: Run Perl tests + run: docker run -i ${{ github.repository }}:test + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ github.repository }} + flavor: | + latest=false + tags: | + type=sha + type=ref,event=branch + type=ref,event=pr + type=raw,value=latest,enable={{is_default_branch}} + - name: Docker meta (sha) + id: docker-sha-tag + uses: docker/metadata-action@v5 + with: + images: ${{ github.repository }} + flavor: | + latest=false + tags: | + type=sha + - name: Build and push + uses: docker/build-push-action@v5 + with: + tags: ${{ steps.meta.outputs.tags }} + annotations: ${{ steps.meta.outputs.annotations }} + - if: contains( fromJSON(steps.meta.outputs.json).tags, "${{ github.repository }}:latest") + run: echo 'need update to ${{ steps.docker-sha-tag.outputs.tags }}'