Skip to content

Commit d530a25

Browse files
Adapt workflow to build from a specific tag
Signed-off-by: GuillaumeBourque-QC <[email protected]>
1 parent c3e5114 commit d530a25

File tree

1 file changed

+33
-9
lines changed

1 file changed

+33
-9
lines changed

.github/workflows/build-indy-node-monitor.yaml

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,48 @@ on:
55
branches:
66
- main
77
paths:
8-
- 'fetch-validator-status/**' # Build only if their are changes in thos directory
8+
- 'fetch-validator-status/**' # Build only if their are changes in this directory
9+
10+
workflow_dispatch:
11+
inputs:
12+
ref:
13+
required: false
14+
type: string
15+
description: "This is the tag version number use to build and publish the container. Don't include the v like this 2.4.6, if you dont provide a version we will get the latest tag version from the repo"
916

1017
jobs:
1118
build:
1219
runs-on: ubuntu-latest
1320

1421
steps:
15-
- name: Checkout repository
16-
uses: actions/checkout@v3
22+
- name: Checkout repository main
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0 # Required due to the way Git works, without it this action won't be able to find any or the correct tags
1726

18-
- name: Log in to GitHub Container Registry
19-
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
27+
- name: Extract latest version from Git tag, excludind the v.
28+
run: |
29+
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1` | cut -c2-)
30+
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
31+
echo "LATEST_TAG=$LATEST_TAG"
2032
21-
- name: Extract version from Git tag
22-
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
33+
- name: Checkout repository specific tag
34+
uses: actions/checkout@v4
35+
with:
36+
ref: v${{ inputs.ref || env.LATEST_TAG }}
37+
38+
- name: Log in to the GitHub Container Registry
39+
uses: docker/login-action@v3
40+
with:
41+
registry: ghcr.io
42+
username: ${{ github.repository_owner }}
43+
password: ${{ secrets.GITHUB_TOKEN }}
44+
45+
- name: Set lowercase username
46+
run: echo "USERNAME=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
2347

2448
- name: Build the Docker image
25-
run: docker build -t ghcr.io/${{ github.actor }}/${{ github.event.repository.name }}/indy-node-monitor:${{ env.VERSION }} .
49+
run: docker build -t ghcr.io/${{ env.USERNAME }}/${{ github.event.repository.name }}/indy-node-monitor:${{ inputs.ref || env.LATEST_TAG }} ./fetch-validator-status/
2650

2751
- name: Push the Docker image
28-
run: docker push ghcr.io/${{ github.actor }}/${{ github.event.repository.name }}/indy-node-monitor:${{ env.VERSION }}
52+
run: docker push ghcr.io/${{ env.USERNAME }}/${{ github.event.repository.name }}/indy-node-monitor:${{ inputs.ref || env.LATEST_TAG }}

0 commit comments

Comments
 (0)