Skip to content

Commit

Permalink
Add tag workflow and update release workflow (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergerad authored Jan 9, 2025
1 parent ffc9055 commit 59b687c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 28 deletions.
17 changes: 3 additions & 14 deletions .github/actions/push/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
19 changes: 5 additions & 14 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/${{ github.repository }}/immutable-geth:latest,ghcr.io/${{ github.repository }}/immutable-geth:${{ env.TAG }}"
22 changes: 22 additions & 0 deletions .github/workflows/tag.yaml
Original file line number Diff line number Diff line change
@@ -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/${{ github.repository }}/immutable-geth:${{ env.TAG }}"

0 comments on commit 59b687c

Please sign in to comment.