From bea9b0cc0aa09b2df16d1388cea220c1e1c766e4 Mon Sep 17 00:00:00 2001 From: Bruno <15909838+thetoolsmith@users.noreply.github.com> Date: Fri, 27 Dec 2024 12:49:01 -0500 Subject: [PATCH 01/27] initial image build and publish workflow --- .github/workflows/build.yml | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..f2d9002 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,41 @@ +name: Build Images + +on: + pull_request: + workflow_run: + workflows: ["Coverage"] + types: + - completed + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - name: 'Checkout GitHub Action' + id: checkout + uses: actions/checkout@v4 + + - name: 'Build Image' + id: build + run: | + docker build -t ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest -f Dockerfile . + + - name: 'Login to GitHub Container Registry' + id: login + uses: docker/login-action@v3 + if: steps.build.conclusion == 'success' + with: + registry: ghcr.io + username: ${{github.actor}} + password: ${{secrets.GITHUB_TOKEN}} + + - name: 'Publish Image' + id: publish + if: github.ref == 'refs/heads/main' && steps.login.conclusion == 'success' + run: | + docker push ghcr.io/cfpb/regtech/sbl/regtech-mail-api --all-tags + From 19887241586876ed759351899143ef50b50557ab Mon Sep 17 00:00:00 2001 From: Bruno <15909838+thetoolsmith@users.noreply.github.com> Date: Fri, 27 Dec 2024 18:09:52 -0500 Subject: [PATCH 02/27] add version get and build with that --- .github/workflows/build.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f2d9002..98cd42d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,10 +19,17 @@ jobs: id: checkout uses: actions/checkout@v4 + - name: Get Version + id: version + run: | + echo "TAG_VERSION=$(cat ../../pyproject.toml | grep '^version.*$' | sed 's/version = //' | tr -d '\"' )" >> $GITHUB_ENV + - name: 'Build Image' id: build run: | docker build -t ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest -f Dockerfile . + docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:${{ steps.version.outputs.TAG_VERSION }} + docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:${{ steps.version.ou tputs.TAG_VERSION }}_${{github.run_attempt}} - name: 'Login to GitHub Container Registry' id: login From a79c65db25fd741cbca08a40b48a0cd72530d825 Mon Sep 17 00:00:00 2001 From: Bruno <15909838+thetoolsmith@users.noreply.github.com> Date: Fri, 27 Dec 2024 18:13:14 -0500 Subject: [PATCH 03/27] fix line wrap --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 98cd42d..1569165 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,7 +29,7 @@ jobs: run: | docker build -t ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest -f Dockerfile . docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:${{ steps.version.outputs.TAG_VERSION }} - docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:${{ steps.version.ou tputs.TAG_VERSION }}_${{github.run_attempt}} + docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:${{ steps.version.outputs.TAG_VERSION }}_${{github.run_attempt}} - name: 'Login to GitHub Container Registry' id: login From 15e622c410efae4057fb812f53c1fff8f02906cc Mon Sep 17 00:00:00 2001 From: Bruno <15909838+thetoolsmith@users.noreply.github.com> Date: Fri, 27 Dec 2024 18:17:10 -0500 Subject: [PATCH 04/27] change triggers --- .github/workflows/build.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1569165..96e79de 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,8 +7,6 @@ on: types: - completed push: - branches: - - main jobs: build: From 5562ca89d1d2d1af25d1beebcfe90909679c716c Mon Sep 17 00:00:00 2001 From: Bruno <15909838+thetoolsmith@users.noreply.github.com> Date: Fri, 27 Dec 2024 18:19:34 -0500 Subject: [PATCH 05/27] change triggers --- .github/workflows/build.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 96e79de..44120b9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,11 +7,13 @@ on: types: - completed push: + branches: + - main jobs: build: runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' }} + #if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - name: 'Checkout GitHub Action' id: checkout From 688a7de961795e5a325a4d60ef6a38a11867498c Mon Sep 17 00:00:00 2001 From: Bruno <15909838+thetoolsmith@users.noreply.github.com> Date: Fri, 27 Dec 2024 18:27:22 -0500 Subject: [PATCH 06/27] fix tag name --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 44120b9..5185dc2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,8 +28,8 @@ jobs: id: build run: | docker build -t ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest -f Dockerfile . - docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:${{ steps.version.outputs.TAG_VERSION }} - docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:${{ steps.version.outputs.TAG_VERSION }}_${{github.run_attempt}} + docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:$TAG_VERSION + docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:$TAG_VERSION_${{github.run_attempt}} - name: 'Login to GitHub Container Registry' id: login From 232907db3bf962c553c3d95b631afd26be4f6b3d Mon Sep 17 00:00:00 2001 From: Bruno <15909838+thetoolsmith@users.noreply.github.com> Date: Fri, 27 Dec 2024 18:37:33 -0500 Subject: [PATCH 07/27] debug dynamic env var --- .github/workflows/build.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5185dc2..3d2b1ed 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,12 +24,17 @@ jobs: run: | echo "TAG_VERSION=$(cat ../../pyproject.toml | grep '^version.*$' | sed 's/version = //' | tr -d '\"' )" >> $GITHUB_ENV + - name: 'Echo test' + run: | + echo TAG_VERSION ${{ steps.version.outputs.TAG_VERSION }} + echo TAG_VERSION ${{ env.TAG_VERSION }} + - name: 'Build Image' id: build run: | docker build -t ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest -f Dockerfile . - docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:$TAG_VERSION - docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:$TAG_VERSION_${{github.run_attempt}} + docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:${{env.TAG_VERSION}} + docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:${{env.TAG_VERSION}}_${{github.run_attempt}} - name: 'Login to GitHub Container Registry' id: login From 80f9d29f9695d5504412cf2a8567d72fde5c9131 Mon Sep 17 00:00:00 2001 From: Bruno <15909838+thetoolsmith@users.noreply.github.com> Date: Fri, 27 Dec 2024 18:49:22 -0500 Subject: [PATCH 08/27] debug dynamic env var --- .github/workflows/build.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3d2b1ed..d0074d2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,8 +26,7 @@ jobs: - name: 'Echo test' run: | - echo TAG_VERSION ${{ steps.version.outputs.TAG_VERSION }} - echo TAG_VERSION ${{ env.TAG_VERSION }} + echo TAG_VERSION $TAG_VERSION - name: 'Build Image' id: build From e2592398458dd24989451f06d06d15001c269398 Mon Sep 17 00:00:00 2001 From: Bruno <15909838+thetoolsmith@users.noreply.github.com> Date: Fri, 27 Dec 2024 18:50:43 -0500 Subject: [PATCH 09/27] debug dynamic env var --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d0074d2..c8df435 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,7 +22,7 @@ jobs: - name: Get Version id: version run: | - echo "TAG_VERSION=$(cat ../../pyproject.toml | grep '^version.*$' | sed 's/version = //' | tr -d '\"' )" >> $GITHUB_ENV + echo "TAG_VERSION=$(cat pyproject.toml | grep '^version.*$' | sed 's/version = //' | tr -d '\"' )" >> $GITHUB_ENV - name: 'Echo test' run: | From 153ebd1704d16fb974b7b098abafa57d5837cae0 Mon Sep 17 00:00:00 2001 From: Bruno <15909838+thetoolsmith@users.noreply.github.com> Date: Thu, 2 Jan 2025 09:42:08 -0500 Subject: [PATCH 10/27] add dependency workflow run --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c8df435..8f05dbd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,7 @@ on: jobs: build: runs-on: ubuntu-latest - #if: ${{ github.event.workflow_run.conclusion == 'success' }} + if: ${{ github.event.workflow_run.status == 'completed' }} && ${{ github.event.workflow_run.conclusion == 'success' }} steps: - name: 'Checkout GitHub Action' id: checkout From 2afc4ad2ec95a88a528197a4438119006d1c94f7 Mon Sep 17 00:00:00 2001 From: Bruno <15909838+thetoolsmith@users.noreply.github.com> Date: Thu, 2 Jan 2025 09:47:18 -0500 Subject: [PATCH 11/27] change dependency --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8f05dbd..69e73f7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,7 @@ name: Build Images on: pull_request: workflow_run: - workflows: ["Coverage"] + workflows: ["Tests"] types: - completed push: @@ -13,7 +13,7 @@ on: jobs: build: runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.status == 'completed' }} && ${{ github.event.workflow_run.conclusion == 'success' }} + if: github.event.workflow_run.status == 'completed' && github.event.workflow_run.conclusion == 'success' steps: - name: 'Checkout GitHub Action' id: checkout From 58da62c83327efe01384cbdddb8e90734d97d226 Mon Sep 17 00:00:00 2001 From: Bruno <15909838+thetoolsmith@users.noreply.github.com> Date: Thu, 2 Jan 2025 09:56:45 -0500 Subject: [PATCH 12/27] trying out some conditionals --- .github/workflows/build.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 69e73f7..6a64820 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,19 +1,18 @@ name: Build Images on: - pull_request: workflow_run: workflows: ["Tests"] types: - completed - push: - branches: - - main + #push: + # branches: + # - main jobs: build: runs-on: ubuntu-latest - if: github.event.workflow_run.status == 'completed' && github.event.workflow_run.conclusion == 'success' + if: ( github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' ) || contains(github.event.push.status.branches, 'main') steps: - name: 'Checkout GitHub Action' id: checkout From 3ec707d0c70c909fe25de40dd32a42982c79d87e Mon Sep 17 00:00:00 2001 From: Bruno <15909838+thetoolsmith@users.noreply.github.com> Date: Thu, 2 Jan 2025 10:00:16 -0500 Subject: [PATCH 13/27] trying out some conditionals --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6a64820..7a05a20 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ on: jobs: build: runs-on: ubuntu-latest - if: ( github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' ) || contains(github.event.push.status.branches, 'main') + if: github.event.workflow_run.conclusion == 'success' || github.ref == 'refs/heads/main' steps: - name: 'Checkout GitHub Action' id: checkout From eaf545b9904a882ce1c1eb8b58879b04bb81edc9 Mon Sep 17 00:00:00 2001 From: Bruno <15909838+thetoolsmith@users.noreply.github.com> Date: Thu, 2 Jan 2025 10:04:59 -0500 Subject: [PATCH 14/27] trying out some conditionals --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7a05a20..7f63fe0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,8 @@ on: jobs: build: runs-on: ubuntu-latest - if: github.event.workflow_run.conclusion == 'success' || github.ref == 'refs/heads/main' + if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' + #if: github.event.workflow_run.conclusion == 'success' steps: - name: 'Checkout GitHub Action' id: checkout From 07593aaf088f401cf806386cb07d21b19bc91c71 Mon Sep 17 00:00:00 2001 From: Bruno <15909838+thetoolsmith@users.noreply.github.com> Date: Thu, 2 Jan 2025 10:16:02 -0500 Subject: [PATCH 15/27] trying out some conditionals --- .github/workflows/build.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7f63fe0..cf5d8bb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,15 +5,14 @@ on: workflows: ["Tests"] types: - completed - #push: - # branches: - # - main + push: + branches: + - main jobs: build: runs-on: ubuntu-latest - if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' - #if: github.event.workflow_run.conclusion == 'success' + if: github.event.workflow_run.status == 'completed' && github.event.workflow_run.conclusion == 'success' steps: - name: 'Checkout GitHub Action' id: checkout @@ -35,6 +34,11 @@ jobs: docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:${{env.TAG_VERSION}} docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:${{env.TAG_VERSION}}_${{github.run_attempt}} + publish: + runs-on: ubuntu-latest + needs: build + if: github.ref == 'refs/heads/main' + steps: - name: 'Login to GitHub Container Registry' id: login uses: docker/login-action@v3 From 5f648394adea02ba070a8ebef94b84addb8c2cd9 Mon Sep 17 00:00:00 2001 From: Bruno <15909838+thetoolsmith@users.noreply.github.com> Date: Thu, 2 Jan 2025 10:21:31 -0500 Subject: [PATCH 16/27] trying out some conditionals --- .github/workflows/build.yml | 2 +- .github/workflows/coverage.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cf5d8bb..580475d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build Images +name: BuildImage on: workflow_run: diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index fd60e93..4c91283 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -2,7 +2,7 @@ name: Coverage on: workflow_run: - workflows: ["Tests"] + workflows: ["BuildImage"] types: - completed @@ -28,4 +28,4 @@ jobs: with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_PR_RUN_ID: ${{ github.event.workflow_run.id }} - verbose: true \ No newline at end of file + verbose: true From eff5c1e25823e585f87b768edaf8d8eddb249b7f Mon Sep 17 00:00:00 2001 From: Bruno <15909838+thetoolsmith@users.noreply.github.com> Date: Thu, 2 Jan 2025 10:24:58 -0500 Subject: [PATCH 17/27] trying out some conditionals --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 580475d..1131b96 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ on: jobs: build: runs-on: ubuntu-latest - if: github.event.workflow_run.status == 'completed' && github.event.workflow_run.conclusion == 'success' + if: ${{ github.event.workflow_run.status == 'completed' }} && ${{ github.event.workflow_run.conclusion == 'success' }} steps: - name: 'Checkout GitHub Action' id: checkout From c4cf07da23ef4a2d54d238220685c66da8a99778 Mon Sep 17 00:00:00 2001 From: Bruno <15909838+thetoolsmith@users.noreply.github.com> Date: Thu, 2 Jan 2025 10:27:42 -0500 Subject: [PATCH 18/27] remove workflow dependency --- .github/workflows/build.yml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1131b96..086d9f8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,10 +1,7 @@ name: BuildImage on: - workflow_run: - workflows: ["Tests"] - types: - - completed + pull_request: push: branches: - main @@ -12,7 +9,6 @@ on: jobs: build: runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.status == 'completed' }} && ${{ github.event.workflow_run.conclusion == 'success' }} steps: - name: 'Checkout GitHub Action' id: checkout @@ -23,10 +19,6 @@ jobs: run: | echo "TAG_VERSION=$(cat pyproject.toml | grep '^version.*$' | sed 's/version = //' | tr -d '\"' )" >> $GITHUB_ENV - - name: 'Echo test' - run: | - echo TAG_VERSION $TAG_VERSION - - name: 'Build Image' id: build run: | From 4b108623411d1e8dfc515ffa6e8cf7bac4d0c710 Mon Sep 17 00:00:00 2001 From: Bruno <15909838+thetoolsmith@users.noreply.github.com> Date: Thu, 2 Jan 2025 11:07:00 -0500 Subject: [PATCH 19/27] test no trigger --- .github/workflows/build.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 086d9f8..da0bcdb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,10 +1,10 @@ name: BuildImage -on: - pull_request: - push: - branches: - - main +#on: +# pull_request: +# push: +# branches: +# - main jobs: build: @@ -42,7 +42,7 @@ jobs: - name: 'Publish Image' id: publish - if: github.ref == 'refs/heads/main' && steps.login.conclusion == 'success' + if: steps.login.conclusion == 'success' run: | docker push ghcr.io/cfpb/regtech/sbl/regtech-mail-api --all-tags From a0e4268804320a6ebc44e7794255a36a4f6b6d81 Mon Sep 17 00:00:00 2001 From: Bruno <15909838+thetoolsmith@users.noreply.github.com> Date: Thu, 2 Jan 2025 11:12:18 -0500 Subject: [PATCH 20/27] test break image, no trigger Coverage --- .github/workflows/build.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index da0bcdb..71d34ac 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,10 +1,10 @@ name: BuildImage -#on: -# pull_request: -# push: -# branches: -# - main +on: + pull_request: + push: + branches: + - main jobs: build: @@ -22,7 +22,7 @@ jobs: - name: 'Build Image' id: build run: | - docker build -t ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest -f Dockerfile . + docker build -t ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest -f DOESNOTEXIST_Dockerfile . docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:${{env.TAG_VERSION}} docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:${{env.TAG_VERSION}}_${{github.run_attempt}} From 172457a140f4109eccb8fd1d06e904e4d7e48f8e Mon Sep 17 00:00:00 2001 From: Bruno <15909838+thetoolsmith@users.noreply.github.com> Date: Thu, 2 Jan 2025 11:16:17 -0500 Subject: [PATCH 21/27] all workflows need to exist in default branch for workflow_run to work --- .github/workflows/build.yml | 2 +- .github/workflows/coverage.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 71d34ac..0162dc4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,7 +22,7 @@ jobs: - name: 'Build Image' id: build run: | - docker build -t ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest -f DOESNOTEXIST_Dockerfile . + docker build -t ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest -f Dockerfile . docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:${{env.TAG_VERSION}} docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:${{env.TAG_VERSION}}_${{github.run_attempt}} diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 4c91283..04e53dc 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -2,7 +2,7 @@ name: Coverage on: workflow_run: - workflows: ["BuildImage"] + workflows: ["Tests"] types: - completed From ca93d87cdb0f7bd8a177515671758a0c4750f88a Mon Sep 17 00:00:00 2001 From: Bruno <15909838+thetoolsmith@users.noreply.github.com> Date: Thu, 2 Jan 2025 11:33:17 -0500 Subject: [PATCH 22/27] 3 tags, latest, build, and semantic version --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0162dc4..335ebaa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,6 +25,7 @@ jobs: docker build -t ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest -f Dockerfile . docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:${{env.TAG_VERSION}} docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:${{env.TAG_VERSION}}_${{github.run_attempt}} + docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest publish: runs-on: ubuntu-latest From 985f9d55cbeca684995b3a084c9566a6fe9d6a73 Mon Sep 17 00:00:00 2001 From: Bruno <15909838+thetoolsmith@users.noreply.github.com> Date: Thu, 2 Jan 2025 11:49:42 -0500 Subject: [PATCH 23/27] move publish in same job as required --- .github/workflows/build.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 335ebaa..c9afa6a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,15 +27,10 @@ jobs: docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:${{env.TAG_VERSION}}_${{github.run_attempt}} docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest - publish: - runs-on: ubuntu-latest - needs: build - if: github.ref == 'refs/heads/main' - steps: - name: 'Login to GitHub Container Registry' id: login uses: docker/login-action@v3 - if: steps.build.conclusion == 'success' + if: ${{ steps.build.conclusion == 'success' }} && ${{ github.ref == 'refs/heads/main' }} with: registry: ghcr.io username: ${{github.actor}} @@ -43,7 +38,7 @@ jobs: - name: 'Publish Image' id: publish - if: steps.login.conclusion == 'success' + if: ${{ steps.login.conclusion == 'success' }} && ${{ github.ref == 'refs/heads/main' }} run: | docker push ghcr.io/cfpb/regtech/sbl/regtech-mail-api --all-tags From 6df336701c01e6b157ea8fd5e35c2492aa32f2ec Mon Sep 17 00:00:00 2001 From: Bruno <15909838+thetoolsmith@users.noreply.github.com> Date: Thu, 2 Jan 2025 11:55:28 -0500 Subject: [PATCH 24/27] why is this trying to publish on a pr --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c9afa6a..2f84736 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,7 +30,7 @@ jobs: - name: 'Login to GitHub Container Registry' id: login uses: docker/login-action@v3 - if: ${{ steps.build.conclusion == 'success' }} && ${{ github.ref == 'refs/heads/main' }} + if: github.ref == 'refs/heads/main' && steps.build.conclusion == 'success' with: registry: ghcr.io username: ${{github.actor}} @@ -38,7 +38,7 @@ jobs: - name: 'Publish Image' id: publish - if: ${{ steps.login.conclusion == 'success' }} && ${{ github.ref == 'refs/heads/main' }} + if: github.ref == 'refs/heads/main' && steps.login.conclusion == 'success' run: | docker push ghcr.io/cfpb/regtech/sbl/regtech-mail-api --all-tags From b7bad19260ef26c2d3437a40b46c80f49b9bcac4 Mon Sep 17 00:00:00 2001 From: Bruno <15909838+thetoolsmith@users.noreply.github.com> Date: Thu, 2 Jan 2025 14:21:55 -0500 Subject: [PATCH 25/27] remove duplicate tag --- .github/workflows/build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2f84736..a146af7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,7 +25,6 @@ jobs: docker build -t ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest -f Dockerfile . docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:${{env.TAG_VERSION}} docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:${{env.TAG_VERSION}}_${{github.run_attempt}} - docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest - name: 'Login to GitHub Container Registry' id: login From d11e9103690e463d11c41c47916f09859064c7ec Mon Sep 17 00:00:00 2001 From: Bruno <15909838+thetoolsmith@users.noreply.github.com> Date: Thu, 2 Jan 2025 16:53:23 -0500 Subject: [PATCH 26/27] make a unique image build number that is also persistent --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a146af7..dca45dc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,7 +24,7 @@ jobs: run: | docker build -t ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest -f Dockerfile . docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:${{env.TAG_VERSION}} - docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:${{env.TAG_VERSION}}_${{github.run_attempt}} + docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:${{env.TAG_VERSION}}_${{github.run_number}}.${{github.run_attempt}} - name: 'Login to GitHub Container Registry' id: login From efa8cf5488d0816746fcfb73bb8c69049154a4d8 Mon Sep 17 00:00:00 2001 From: Bruno <15909838+thetoolsmith@users.noreply.github.com> Date: Wed, 8 Jan 2025 14:39:06 -0500 Subject: [PATCH 27/27] change image name to test GHA to GHCR --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dca45dc..5b61ac1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,9 +22,9 @@ jobs: - name: 'Build Image' id: build run: | - docker build -t ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest -f Dockerfile . - docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:${{env.TAG_VERSION}} - docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:${{env.TAG_VERSION}}_${{github.run_number}}.${{github.run_attempt}} + docker build -t ghcr.io/cfpb/regtech/sbl/regtech-mail-api-latest:latest -f Dockerfile . + docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api-latest:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:${{env.TAG_VERSION}} + docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api-latest:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:${{env.TAG_VERSION}}_${{github.run_number}}.${{github.run_attempt}} - name: 'Login to GitHub Container Registry' id: login @@ -39,5 +39,5 @@ jobs: id: publish if: github.ref == 'refs/heads/main' && steps.login.conclusion == 'success' run: | - docker push ghcr.io/cfpb/regtech/sbl/regtech-mail-api --all-tags + docker push ghcr.io/cfpb/regtech/sbl/regtech-mail-api-latest --all-tags