From ab1df44add663601246c50f7bbeed171976c507e Mon Sep 17 00:00:00 2001 From: aaronskiba Date: Fri, 20 Dec 2024 10:48:28 -0700 Subject: [PATCH] Refactor: Combine `docker-push-*.yml` files Deleted `docker-push-uat-image.yml` and moved its logic to `docker-push-image.yml`. This maintains all of the same functionality that existed between the two files and better aligns with DRY principles. --- .github/workflows/docker-push-image.yml | 10 +++++ .github/workflows/docker-push-uat-image.yml | 42 --------------------- 2 files changed, 10 insertions(+), 42 deletions(-) delete mode 100644 .github/workflows/docker-push-uat-image.yml diff --git a/.github/workflows/docker-push-image.yml b/.github/workflows/docker-push-image.yml index bc05b21569..62b80ecd5f 100644 --- a/.github/workflows/docker-push-image.yml +++ b/.github/workflows/docker-push-image.yml @@ -8,6 +8,9 @@ name: Publish Docker image on: release: types: [published] + push: + tags: + - '*-uat-*' jobs: push_to_registry: @@ -28,9 +31,16 @@ jobs: uses: docker/metadata-action@v3 with: images: ualbertalib/dmp_roadmap + # GitHub tag matching and Docker tag generation are contingent on the event type + # (The event type is either 'release' or 'push' of a '*-uat-*' tag) tags: | + ${{ github.event_name == 'release' && ' type=match,pattern=.+portage-(\d\.\d\.\d),group=1 type=raw,value=production + ' || ' + type=match,pattern=.+portage-(\d+\.\d+\.\d+-uat-\d+),group=1 + type=raw,value=uat + ' }} - name: Build and push Docker image uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc diff --git a/.github/workflows/docker-push-uat-image.yml b/.github/workflows/docker-push-uat-image.yml deleted file mode 100644 index 364a7a9a08..0000000000 --- a/.github/workflows/docker-push-uat-image.yml +++ /dev/null @@ -1,42 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -name: Publish Docker UAT image - -on: - push: - tags: - - '*-uat-*' - -jobs: - push_to_registry: - name: Push Docker UAT image to Docker Hub - runs-on: ubuntu-20.04 - steps: - - name: Check out the repo - uses: actions/checkout@v3 - - - name: Log in to Docker Hub - uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Extract metadata (tags) for Docker - id: meta - uses: docker/metadata-action@v3 - with: - images: ualbertalib/dmp_roadmap - tags: | - type=match,pattern=.+portage-(\d+\.\d+\.\d+-uat-\d+),group=1 - type=raw,value=uat - - - name: Build and push Docker image - uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc - with: - context: . - file: Dockerfile.production - push: true - tags: ${{ steps.meta.outputs.tags }}