From 9231c0e0703652fd583eb85167de7b0e995aabdf Mon Sep 17 00:00:00 2001 From: sergerad Date: Fri, 10 Jan 2025 10:24:11 +1300 Subject: [PATCH 1/2] Add tag workflow and update release workflow --- .github/actions/push/action.yaml | 17 +++-------------- .github/workflows/main.yaml | 10 ++++++++++ .github/workflows/release.yaml | 19 +++++-------------- .github/workflows/tag.yaml | 22 ++++++++++++++++++++++ 4 files changed, 40 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/tag.yaml diff --git a/.github/actions/push/action.yaml b/.github/actions/push/action.yaml index 36bb941eb..0242f1a4e 100644 --- a/.github/actions/push/action.yaml +++ b/.github/actions/push/action.yaml @@ -4,9 +4,10 @@ name: Docker Build + Push inputs: github-token: required: true - image-tag: + tags: required: false type: string + description: "Comma separated list of Docker tags (e.g. ghcr.io/immutable/immutable-geth/immutable-geth:latest)" dockerfile: required: false type: string @@ -32,18 +33,6 @@ runs: images: ghcr.io/${{ github.repository }}/s github-token: ${{ inputs.github-token }} - - name: Image tag - shell: bash - run: | - REPOSITORY_NAME="$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" - if [ -z ${{ inputs.image_tag }} ]; then - BUILD_TIMESTAMP="$(date +%s)" - SHORT_SHA="$(git rev-parse --short HEAD)" - echo GHCR_TAG="ghcr.io/${{ github.repository }}/immutable-geth:develop-$BUILD_TIMESTAMP-git.$SHORT_SHA" >> $GITHUB_ENV - else - echo GHCR_TAG="ghcr.io/${{ github.repository }}/immutable-geth:${{ inputs.image-tag }}" >> $GITHUB_ENV - fi - - name: Restore Go mod (pkg) uses: actions/cache/restore@v3 with: @@ -85,7 +74,7 @@ runs: file: ${{ inputs.dockerfile }} push: true build-args: ${{ inputs.build-args }} - tags: ${{ env.GHCR_TAG }} + tags: ${{ input.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/immutable-geth:cache cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/immutable-geth:cache,mode=max diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 47a294237..64dce3f90 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -13,6 +13,16 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + + - name: Tags + shell: bash + run: | + REPOSITORY_NAME="$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" + BUILD_TIMESTAMP="$(date +%s)" + SHORT_SHA="$(git rev-parse --short HEAD)" + echo TAGS="ghcr.io/${{ github.repository }}/immutable-geth:develop-$BUILD_TIMESTAMP-git.$SHORT_SHA" >> $GITHUB_ENV + - uses: ./.github/actions/push with: github-token: ${{ secrets.GITHUB_TOKEN }} + tags: ${{ env.TAGS }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 13fcc234f..d66d28626 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -5,26 +5,17 @@ on: types: [published] jobs: - setup: - name: Setup Envs - runs-on: ubuntu-latest - outputs: - tag-name: ${{ steps.get-tag-for-release.outputs.TAG_NAME }} - steps: - - name: Extract tag name for the release - id: get-tag-for-release - run: echo "TAG_NAME=$(echo ${GITHUB_REF} | sed 's/refs\/tags\///')" >> $GITHUB_OUTPUT - - name: Print tag being deployed - run: echo "The tag name being deployed is ${{ steps.get-tag-for-release.outputs.TAG_NAME }}." - push: name: Push Docker - needs: [setup] runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 + + - name: Set Release Tag + run: echo "TAG=$(echo ${GITHUB_REF} | sed 's/refs\/tags\///')" >> $GITHUB_ENV + - uses: ./.github/actions/push with: github-token: ${{ secrets.GITHUB_TOKEN }} - image-tag: ${{ needs.setup.outputs.tag-name }} + tags: "ghcr.io/immutable/immutable-geth:latest,ghcr.io/immutable/immutable-geth:${{ env.TAG }}" diff --git a/.github/workflows/tag.yaml b/.github/workflows/tag.yaml new file mode 100644 index 000000000..d0a4a012d --- /dev/null +++ b/.github/workflows/tag.yaml @@ -0,0 +1,22 @@ +name: Tag + +on: + push: + tags: + - "**" + +jobs: + push: + name: Push Docker + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set Release Tag + run: echo "TAG=$(echo ${GITHUB_REF} | sed 's/refs\/tags\///')" >> $GITHUB_ENV + + - uses: ./.github/actions/push + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + tags: "ghcr.io/immutable/immutable-geth:${{ env.TAG }}" From d7983af5102c0c69e7dec48ac4512c178134f07c Mon Sep 17 00:00:00 2001 From: sergerad Date: Fri, 10 Jan 2025 10:37:12 +1300 Subject: [PATCH 2/2] Fix tags --- .github/workflows/release.yaml | 2 +- .github/workflows/tag.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index d66d28626..4783b03b1 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -18,4 +18,4 @@ jobs: - uses: ./.github/actions/push with: github-token: ${{ secrets.GITHUB_TOKEN }} - tags: "ghcr.io/immutable/immutable-geth:latest,ghcr.io/immutable/immutable-geth:${{ env.TAG }}" + tags: "ghcr.io/${{ github.repository }}/immutable-geth:latest,ghcr.io/${{ github.repository }}/immutable-geth:${{ env.TAG }}" diff --git a/.github/workflows/tag.yaml b/.github/workflows/tag.yaml index d0a4a012d..f34469b23 100644 --- a/.github/workflows/tag.yaml +++ b/.github/workflows/tag.yaml @@ -19,4 +19,4 @@ jobs: - uses: ./.github/actions/push with: github-token: ${{ secrets.GITHUB_TOKEN }} - tags: "ghcr.io/immutable/immutable-geth:${{ env.TAG }}" + tags: "ghcr.io/${{ github.repository }}/immutable-geth:${{ env.TAG }}"