|
5 | 5 | branches: |
6 | 6 | - main |
7 | 7 | 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" |
9 | 16 |
|
10 | 17 | jobs: |
11 | 18 | build: |
12 | 19 | runs-on: ubuntu-latest |
13 | 20 |
|
14 | 21 | 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 |
17 | 26 |
|
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" |
20 | 32 |
|
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 |
23 | 47 |
|
24 | 48 | - 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/ |
26 | 50 |
|
27 | 51 | - 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