Skip to content

Adapt workflow to build from a specific tag #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions .github/workflows/build-indy-node-monitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Publish Docker image

on:
push:
branches:
- main
paths:
- 'fetch-validator-status/**' # Build only if their are changes in this directory

workflow_dispatch:
inputs:
ref:
required: false
type: string
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"

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository main
uses: actions/checkout@v4
with:
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

- name: Extract latest version from Git tag, excludind the v.
run: |
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1` | cut -c2-)
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
echo "LATEST_TAG=$LATEST_TAG"

- name: Checkout repository specific tag
uses: actions/checkout@v4
with:
ref: v${{ inputs.ref || env.LATEST_TAG }}

- name: Log in to the GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set lowercase username
run: echo "USERNAME=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Checkout repository main
uses: actions/checkout@v4
with:
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

- name: Extract latest version from Git tag, excludind the v.
run: |
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1` | cut -c2-)
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
echo "LATEST_TAG=$LATEST_TAG"

- name: Checkout repository specific tag
uses: actions/checkout@v4
with:
ref: v${{ inputs.ref || env.LATEST_TAG }}

- name: Log in to the GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set lowercase username
run: echo "USERNAME=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole section of code seems to be duplicated.

Copy link
Contributor Author

@GuillaumeBourque-QC GuillaumeBourque-QC Oct 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes if we go the TAG way we first need to checkout de main code and then get the latest TAG from the code and then we can checkout the correct version for the build.

Since we limit the change to the fetch-valdator-status path the build will not be launch very often but going with the release make sense.

Right now I am asinged on a new task in Sylvain team, but if you want to go the relaese way that would be a good way forward, but I will have limited bandwith for the next few weeks.

Best.


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

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