Skip to content

Commit acc8df9

Browse files
Adapt workflow to build from a specific tag
1 parent d530a25 commit acc8df9

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

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

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
ref:
1313
required: false
1414
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"
15+
description: "This is the tag version, don't include the v like this 2.4.6, if you dont provide a version we will get the latest tag"
1616

1717
jobs:
1818
build:
@@ -42,11 +42,38 @@ jobs:
4242
username: ${{ github.repository_owner }}
4343
password: ${{ secrets.GITHUB_TOKEN }}
4444

45+
- name: Set lowercase username
46+
run: echo "USERNAME=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
47+
- name: Checkout repository main
48+
uses: actions/checkout@v4
49+
with:
50+
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
51+
52+
- name: Extract latest version from Git tag, excludind the v.
53+
run: |
54+
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1` | cut -c2-)
55+
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
56+
echo "LATEST_TAG=$LATEST_TAG"
57+
58+
- name: Checkout repository specific tag
59+
uses: actions/checkout@v4
60+
with:
61+
ref: v${{ inputs.ref || env.LATEST_TAG }}
62+
63+
- name: Log in to the GitHub Container Registry
64+
uses: docker/login-action@v3
65+
with:
66+
registry: ghcr.io
67+
username: ${{ github.repository_owner }}
68+
password: ${{ secrets.GITHUB_TOKEN }}
69+
4570
- name: Set lowercase username
4671
run: echo "USERNAME=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
4772

4873
- name: Build the Docker image
4974
run: docker build -t ghcr.io/${{ env.USERNAME }}/${{ github.event.repository.name }}/indy-node-monitor:${{ inputs.ref || env.LATEST_TAG }} ./fetch-validator-status/
75+
run: docker build -t ghcr.io/${{ env.USERNAME }}/${{ github.event.repository.name }}/indy-node-monitor:${{ inputs.ref || env.LATEST_TAG }} ./fetch-validator-status/
5076

5177
- name: Push the Docker image
5278
run: docker push ghcr.io/${{ env.USERNAME }}/${{ github.event.repository.name }}/indy-node-monitor:${{ inputs.ref || env.LATEST_TAG }}
79+
run: docker push ghcr.io/${{ env.USERNAME }}/${{ github.event.repository.name }}/indy-node-monitor:${{ inputs.ref || env.LATEST_TAG }}

0 commit comments

Comments
 (0)