From 46a316b837b259de8a1d0f175a1690d134c5f4ea Mon Sep 17 00:00:00 2001 From: max funk Date: Fri, 20 Dec 2024 14:44:21 -0700 Subject: [PATCH] tag current short sha and latest when pushing images to github --- .github/workflows/build-all-images.yaml | 130 ++++++++++++++---------- 1 file changed, 78 insertions(+), 52 deletions(-) diff --git a/.github/workflows/build-all-images.yaml b/.github/workflows/build-all-images.yaml index a356368a..eb626fee 100644 --- a/.github/workflows/build-all-images.yaml +++ b/.github/workflows/build-all-images.yaml @@ -19,16 +19,18 @@ jobs: - uses: actions/checkout@v4 - name: build image run: bash scripts/build-image-job.sh --service-name $SERVICE_NAME --build-ctx . - - name: tag image - run: docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest + - name: tag image with current short sha and latest + run: | + docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:${GITHUB_SHA:0:7} + docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest - name: log into container registry uses: docker/login-action@v3 with: registry: ${{ env.GITHUB_REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: push image - run: docker push ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest + - name: push images + run: docker push --all-tags ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME balance_by_account: name: balance-by-account runs-on: ubuntu-latest @@ -38,16 +40,18 @@ jobs: - uses: actions/checkout@v4 - name: build image run: bash scripts/build-image-job.sh --service-name $SERVICE_NAME --build-ctx . - - name: tag image - run: docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest + - name: tag image with current short sha and latest + run: | + docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:${GITHUB_SHA:0:7} + docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest - name: log into container registry uses: docker/login-action@v3 with: registry: ${{ env.GITHUB_REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: push image - run: docker push ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest + - name: push images + run: docker push --all-tags ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME graphql: name: graphql runs-on: ubuntu-latest @@ -57,16 +61,18 @@ jobs: - uses: actions/checkout@v4 - name: build image run: bash scripts/build-image-job.sh --service-name $SERVICE_NAME --build-ctx . - - name: tag image - run: docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest + - name: tag image with current short sha and latest + run: | + docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:${GITHUB_SHA:0:7} + docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest - name: log into container registry uses: docker/login-action@v3 with: registry: ${{ env.GITHUB_REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: push image - run: docker push ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest + - name: push images + run: docker push --all-tags ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME request_create: name: request-create runs-on: ubuntu-latest @@ -76,16 +82,18 @@ jobs: - uses: actions/checkout@v4 - name: build image run: bash scripts/build-image-job.sh --service-name $SERVICE_NAME --build-ctx . - - name: tag image - run: docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest + - name: tag image with current short sha and latest + run: | + docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:${GITHUB_SHA:0:7} + docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest - name: log into container registry uses: docker/login-action@v3 with: registry: ${{ env.GITHUB_REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: push image - run: docker push ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest + - name: push images + run: docker push --all-tags ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME request_approve: name: request-approve runs-on: ubuntu-latest @@ -95,16 +103,18 @@ jobs: - uses: actions/checkout@v4 - name: build image run: bash scripts/build-image-job.sh --service-name $SERVICE_NAME --build-ctx . - - name: tag image - run: docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest + - name: tag image with current short sha and latest + run: | + docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:${GITHUB_SHA:0:7} + docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest - name: log into container registry uses: docker/login-action@v3 with: registry: ${{ env.GITHUB_REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: push image - run: docker push ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest + - name: push images + run: docker push --all-tags ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME request_by_id: name: request-by-id runs-on: ubuntu-latest @@ -114,16 +124,18 @@ jobs: - uses: actions/checkout@v4 - name: build image run: bash scripts/build-image-job.sh --service-name $SERVICE_NAME --build-ctx . - - name: tag image - run: docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest + - name: tag image with current short sha and latest + run: | + docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:${GITHUB_SHA:0:7} + docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest - name: log into container registry uses: docker/login-action@v3 with: registry: ${{ env.GITHUB_REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: push image - run: docker push ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest + - name: push images + run: docker push --all-tags ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME requests_by_account: name: requests-by-account runs-on: ubuntu-latest @@ -133,16 +145,18 @@ jobs: - uses: actions/checkout@v4 - name: build image run: bash scripts/build-image-job.sh --service-name $SERVICE_NAME --build-ctx . - - name: tag image - run: docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest + - name: tag image with current short sha and latest + run: | + docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:${GITHUB_SHA:0:7} + docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest - name: log into container registry uses: docker/login-action@v3 with: registry: ${{ env.GITHUB_REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: push image - run: docker push ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest + - name: push images + run: docker push --all-tags ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME transaction_by_id: name: transaction-by-id runs-on: ubuntu-latest @@ -152,16 +166,18 @@ jobs: - uses: actions/checkout@v4 - name: build image run: bash scripts/build-image-job.sh --service-name $SERVICE_NAME --build-ctx . - - name: tag image - run: docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest + - name: tag image with current short sha and latest + run: | + docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:${GITHUB_SHA:0:7} + docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest - name: log into container registry uses: docker/login-action@v3 with: registry: ${{ env.GITHUB_REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: push image - run: docker push ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest + - name: push images + run: docker push --all-tags ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME transactions_by_account: name: transactions-by-account runs-on: ubuntu-latest @@ -171,16 +187,18 @@ jobs: - uses: actions/checkout@v4 - name: build image run: bash scripts/build-image-job.sh --service-name $SERVICE_NAME --build-ctx . - - name: tag image - run: docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest + - name: tag image with current short sha and latest + run: | + docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:${GITHUB_SHA:0:7} + docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest - name: log into container registry uses: docker/login-action@v3 with: registry: ${{ env.GITHUB_REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: push image - run: docker push ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest + - name: push images + run: docker push --all-tags ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME event: name: event runs-on: ubuntu-latest @@ -190,16 +208,18 @@ jobs: - uses: actions/checkout@v4 - name: build image run: bash scripts/build-image-job.sh --service-name $SERVICE_NAME --build-ctx . - - name: tag image - run: docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest + - name: tag image with current short sha and latest + run: | + docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:${GITHUB_SHA:0:7} + docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest - name: log into container registry uses: docker/login-action@v3 with: registry: ${{ env.GITHUB_REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: push image - run: docker push ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest + - name: push images + run: docker push --all-tags ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME measure: name: measure runs-on: ubuntu-latest @@ -209,16 +229,18 @@ jobs: - uses: actions/checkout@v4 - name: build image run: bash scripts/build-image-job.sh --service-name $SERVICE_NAME --build-ctx . - - name: tag image - run: docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest + - name: tag image with current short sha and latest + run: | + docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:${GITHUB_SHA:0:7} + docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest - name: log into container registry uses: docker/login-action@v3 with: registry: ${{ env.GITHUB_REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: push image - run: docker push ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest + - name: push images + run: docker push --all-tags ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME auto_confirm: name: auto-confirm runs-on: ubuntu-latest @@ -228,16 +250,18 @@ jobs: - uses: actions/checkout@v4 - name: build image run: bash scripts/build-image-job.sh --service-name $SERVICE_NAME --build-ctx . - - name: tag image - run: docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest + - name: tag image with current short sha and latest + run: | + docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:${GITHUB_SHA:0:7} + docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest - name: log into container registry uses: docker/login-action@v3 with: registry: ${{ env.GITHUB_REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: push image - run: docker push ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest + - name: push images + run: docker push --all-tags ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME go_migrate: name: go-migrate runs-on: ubuntu-latest @@ -247,13 +271,15 @@ jobs: - uses: actions/checkout@v4 - name: build image run: bash scripts/build-image-job.sh --service-name $SERVICE_NAME --build-ctx ./migrations/go-migrate # non root build context - - name: tag image - run: docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest + - name: tag image with current short sha and latest + run: | + docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:${GITHUB_SHA:0:7} + docker tag $SERVICE_NAME:latest ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest - name: log into container registry uses: docker/login-action@v3 with: registry: ${{ env.GITHUB_REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: push image - run: docker push ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME:latest \ No newline at end of file + - name: push images + run: docker push --all-tags ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}/$SERVICE_NAME \ No newline at end of file