From e459993bc36830751f0b60366432e36c2f287dce Mon Sep 17 00:00:00 2001 From: Joseph Salmingo Date: Tue, 12 Nov 2024 09:43:56 -0800 Subject: [PATCH] add Docker build release action --- .github/workflows/Docker-build-release.yaml | 62 +++++++-------------- 1 file changed, 21 insertions(+), 41 deletions(-) diff --git a/.github/workflows/Docker-build-release.yaml b/.github/workflows/Docker-build-release.yaml index 6a9218e..e33a8f8 100644 --- a/.github/workflows/Docker-build-release.yaml +++ b/.github/workflows/Docker-build-release.yaml @@ -1,53 +1,33 @@ --- -name: Docker-build-release +name: Update image in GHCR + +run-name: > + ${{ + github.event_name == 'delete' && format( + 'Delete `{0}{1}`', + github.event.ref_type == 'branch' && 'branch-' || '', + github.event.ref + ) + || github.ref == 'refs/heads/main' && 'Update `dev`' + || format( + 'Update `{0}{1}`', + !startsWith(github.ref, 'refs/tags') && 'branch-' || '', + github.ref_name + ) + }} docker tag on: push: - branches: ['main'] + branches-ignore: ['gh-pages'] tags: ['v*'] - release: - types: [published] + delete: jobs: - build-and-push-image: + push-or-delete-image: runs-on: ubuntu-latest - name: A job to build and push a docker image + name: Update GitHub Container Registry permissions: contents: read packages: write - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Read YAML - id: yaml-data - uses: jbutcher5/read-yaml@1.6 - with: - file: metadata.yaml - key-path: '["image_name"]' - - - name: Create tags - id: meta - uses: docker/metadata-action@v3 - with: - flavor: | - latest=false - images: ghcr.io/uclahs-cds/${{ steps.yaml-data.outputs.data }} - tags: | - type=raw,enable=${{github.event_name == 'push'}},value=dev,event=branch - type=match,pattern=v(.*),group=1 - - name: Log in to the Container registry - uses: docker/login-action@v1 - with: - registry: ghcr.io/uclahs-cds - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push Docker image - uses: docker/build-push-action@v2 - with: - context: . - push: true - tags: ${{ steps.meta.outputs.tags }} - file: ./docker/Dockerfile + - uses: uclahs-cds/tool-Docker-action@v2