From 63dcd540416bad839ad474254783630168680c4a Mon Sep 17 00:00:00 2001 From: Gary Yendell Date: Tue, 25 Jun 2024 12:23:24 +0000 Subject: [PATCH] WIP --- .github/workflows/container.yml | 46 ++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml index b3ccd36..998f3fe 100644 --- a/.github/workflows/container.yml +++ b/.github/workflows/container.yml @@ -2,12 +2,6 @@ name: Container CI on: push: - # Build for main, tags and PRs - # Builds from PRs are not pushed to the registry because of rules in the steps - branches: - - main - tags: - - "*" pull_request: jobs: @@ -17,9 +11,6 @@ jobs: contents: read packages: write - env: - TAG: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }} - steps: - name: Checkout uses: actions/checkout@v2 @@ -56,24 +47,55 @@ jobs: cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache + release: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }} + needs: [build] + + steps: + - name: Create tags for developer image + id: meta-developer + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=ref,event=tag + type=raw,value=latest + - name: Push developer image + if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }} uses: docker/build-push-action@v4 with: context: . file: Dockerfile target: developer - tags: ${{ env.TAG }}-developer:latest + tags: ${{ steps.meta-developer.outputs.tags }} + labels: ${{ steps.meta-developer.outputs.labels }} push: ${{ github.event_name != 'pull_request' }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache + - name: Create tags for runtime image + id: meta-runtime + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=ref,event=tag + type=raw,value=latest + - name: Push runtime image + if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }} uses: docker/build-push-action@v4 with: context: . file: Dockerfile target: runtime - tags: ${{ env.TAG }}-runtime:latest - push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta-runtime.outputs.tags }} + labels: ${{ steps.meta-runtime.outputs.labels }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache