From ff02dbb2b80fa7f34b945e8b54df9a89567844a6 Mon Sep 17 00:00:00 2001 From: Joey Zhou Date: Thu, 30 May 2024 08:23:31 -0700 Subject: [PATCH 1/3] ci: rework release retag --- .github/workflows/release.yaml | 28 ---------------------- .github/workflows/release_retag.yaml | 36 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 28 deletions(-) delete mode 100644 .github/workflows/release.yaml create mode 100644 .github/workflows/release_retag.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml deleted file mode 100644 index d88bb631dae..00000000000 --- a/.github/workflows/release.yaml +++ /dev/null @@ -1,28 +0,0 @@ -name: Retag and Push Docker Image on Release - -on: - release: - types: [published] - -jobs: - retag-and-push: - runs-on: ubuntu-latest - - steps: - - name: Check out the repo - uses: actions/checkout@v4 - - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Pull Docker image with commit tag - run: docker pull mozilla/blurts-server:${{ github.event.release.target_commitish }} - - - name: Tag Docker image with release tag - run: docker tag mozilla/blurts-server:${{ github.event.release.target_commitish }} mozilla/blurts-server:${{ github.event.release.tag_name }} - - - name: Push Docker image with release tag - run: docker push mozilla/blurts-server:${{ github.event.release.tag_name }} diff --git a/.github/workflows/release_retag.yaml b/.github/workflows/release_retag.yaml new file mode 100644 index 00000000000..1379df56566 --- /dev/null +++ b/.github/workflows/release_retag.yaml @@ -0,0 +1,36 @@ +name: Retag and Push Docker Image on Release +# GH release should always create a tag automatically +on: + push: + tags: + - '*' + +jobs: + retag-and-push: + runs-on: ubuntu-latest + + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Extract tag + id: extract_tag + run: echo "::set-output name=TAG::${GITHUB_REF#refs/tags/}" + + - name: Extract commit SHA + id: extract_sha + run: echo "::set-output name=COMMIT_SHA::${GITHUB_SHA}" + + - name: Pull Docker image with commit tag + run: docker pull mozilla/blurts-server:${{ steps.extract_sha.outputs.COMMIT_SHA }} + + - name: Tag Docker image with release tag + run: docker tag mozilla/blurts-server:${{ steps.extract_sha.outputs.COMMIT_SHA }} mozilla/blurts-server:${{ steps.extract_tag.outputs.TAG }} + + - name: Push Docker image with release tag + run: docker push mozilla/blurts-server:${{ steps.extract_tag.outputs.TAG }} From 2ada006dd064ef457d59dd2c88257d69f3a5db6a Mon Sep 17 00:00:00 2001 From: Joey Zhou Date: Thu, 30 May 2024 10:37:57 -0700 Subject: [PATCH 2/3] ci: grab short form github sha --- .github/workflows/release_retag.yaml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release_retag.yaml b/.github/workflows/release_retag.yaml index 1379df56566..379cb2c4887 100644 --- a/.github/workflows/release_retag.yaml +++ b/.github/workflows/release_retag.yaml @@ -18,19 +18,19 @@ jobs: with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Extract tag - id: extract_tag - run: echo "::set-output name=TAG::${GITHUB_REF#refs/tags/}" - - - name: Extract commit SHA - id: extract_sha - run: echo "::set-output name=COMMIT_SHA::${GITHUB_SHA}" + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: mozilla/blurts-server + tags: type=sha,format=short,prefix= - name: Pull Docker image with commit tag - run: docker pull mozilla/blurts-server:${{ steps.extract_sha.outputs.COMMIT_SHA }} + run: docker pull mozilla/blurts-server:${{ steps.meta.outputs.tags }} - name: Tag Docker image with release tag - run: docker tag mozilla/blurts-server:${{ steps.extract_sha.outputs.COMMIT_SHA }} mozilla/blurts-server:${{ steps.extract_tag.outputs.TAG }} + run: docker tag mozilla/blurts-server:${{ steps.meta.outputs.tags }} mozilla/blurts-server:${{ github.ref_name }} - name: Push Docker image with release tag - run: docker push mozilla/blurts-server:${{ steps.extract_tag.outputs.TAG }} + run: docker push mozilla/blurts-server:${{ github.ref_name }} From 1e2582cb29cad6618f810c509f56d07d72db4682 Mon Sep 17 00:00:00 2001 From: Joey Zhou Date: Thu, 30 May 2024 10:39:45 -0700 Subject: [PATCH 3/3] ci: tags from meta output contains the repo names etc --- .github/workflows/release_retag.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release_retag.yaml b/.github/workflows/release_retag.yaml index 379cb2c4887..a9b6d38b2ae 100644 --- a/.github/workflows/release_retag.yaml +++ b/.github/workflows/release_retag.yaml @@ -27,10 +27,10 @@ jobs: tags: type=sha,format=short,prefix= - name: Pull Docker image with commit tag - run: docker pull mozilla/blurts-server:${{ steps.meta.outputs.tags }} + run: docker pull ${{ steps.meta.outputs.tags }} - name: Tag Docker image with release tag - run: docker tag mozilla/blurts-server:${{ steps.meta.outputs.tags }} mozilla/blurts-server:${{ github.ref_name }} + run: docker tag ${{ steps.meta.outputs.tags }} mozilla/blurts-server:${{ github.ref_name }} - name: Push Docker image with release tag run: docker push mozilla/blurts-server:${{ github.ref_name }}