From 9d83c3aa55a27cf9668c1047ff2f5e59773303ad Mon Sep 17 00:00:00 2001 From: GuillaumeBourque-QC Date: Fri, 18 Oct 2024 18:43:47 -0400 Subject: [PATCH 1/4] Adapt workflow to build from a specific tag Signed-off-by: GuillaumeBourque-QC --- .../workflows/build-indy-node-monitor.yaml | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 .github/workflows/build-indy-node-monitor.yaml diff --git a/.github/workflows/build-indy-node-monitor.yaml b/.github/workflows/build-indy-node-monitor.yaml new file mode 100644 index 0000000..fbd9c43 --- /dev/null +++ b/.github/workflows/build-indy-node-monitor.yaml @@ -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 + + - 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 }} From 236abdc19459cef36d5ce70565defe2e9aac46ea Mon Sep 17 00:00:00 2001 From: GuillaumeBourque-QC Date: Thu, 7 Nov 2024 16:10:13 -0500 Subject: [PATCH 2/4] Test new release Signed-off-by: GuillaumeBourque-QC --- .../workflows/build-indy-node-monitor.yaml | 92 +++++++++---------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/.github/workflows/build-indy-node-monitor.yaml b/.github/workflows/build-indy-node-monitor.yaml index fbd9c43..5099d32 100644 --- a/.github/workflows/build-indy-node-monitor.yaml +++ b/.github/workflows/build-indy-node-monitor.yaml @@ -1,11 +1,9 @@ name: Publish Docker image on: - push: - branches: - - main - paths: - - 'fetch-validator-status/**' # Build only if their are changes in this directory + release: + types: [created] # Triggers only when a new release is created + workflow_dispatch: inputs: @@ -24,54 +22,56 @@ jobs: 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. + - name: Display release information 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" + echo "New release created!" + echo "Release tag: ${{ github.event.release.tag_name }}" + echo "Release name: ${{ github.event.release.name }}" + echo "Release body: ${{ github.event.release.body }}" - - 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: Checkout repository specific tag + # uses: actions/checkout@v4 + # with: + # ref: v${{ inputs.ref || env.LATEST_TAG }} - - 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: 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: 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: 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: Checkout repository specific tag - uses: actions/checkout@v4 - with: - ref: v${{ inputs.ref || env.LATEST_TAG }} + # - 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: 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: 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: Set lowercase username + # run: echo "USERNAME=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV - - 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: 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 }} + # - name: Push the Docker image + # run: docker push ghcr.io/${{ env.USERNAME }}/${{ github.event.repository.name }}/indy-node-monitor:${{ inputs.ref || env.LATEST_TAG }} From 2517832bdc7ffcaec32f2a815efc23d3a0f4e178 Mon Sep 17 00:00:00 2001 From: GuillaumeBourque-QC Date: Thu, 7 Nov 2024 17:06:53 -0500 Subject: [PATCH 3/4] Test new release Signed-off-by: GuillaumeBourque-QC --- .github/workflows/build-indy-node-monitor.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-indy-node-monitor.yaml b/.github/workflows/build-indy-node-monitor.yaml index 5099d32..7832c83 100644 --- a/.github/workflows/build-indy-node-monitor.yaml +++ b/.github/workflows/build-indy-node-monitor.yaml @@ -2,7 +2,7 @@ name: Publish Docker image on: release: - types: [created] # Triggers only when a new release is created + types: [published] # Triggers only when a new release is created workflow_dispatch: From d2c54aec8f228ddbc02f9b9e70bdce62de795aec Mon Sep 17 00:00:00 2001 From: GuillaumeBourque-QC Date: Fri, 8 Nov 2024 16:30:39 -0500 Subject: [PATCH 4/4] Coreect docker build workflow Signed-off-by: GuillaumeBourque-QC --- .../workflows/build-indy-node-monitor.yaml | 63 +++++++------------ 1 file changed, 24 insertions(+), 39 deletions(-) diff --git a/.github/workflows/build-indy-node-monitor.yaml b/.github/workflows/build-indy-node-monitor.yaml index 7832c83..6389e1b 100644 --- a/.github/workflows/build-indy-node-monitor.yaml +++ b/.github/workflows/build-indy-node-monitor.yaml @@ -30,48 +30,33 @@ jobs: echo "Release body: ${{ github.event.release.body }}" - # - 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: Checkout repository specific tag + uses: actions/checkout@v4 + with: + ref: ${{ github.event.release.name }} # Ex release name: v0.0.1 - # - 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: 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: Checkout repository specific tag - # uses: actions/checkout@v4 - # with: - # ref: v${{ inputs.ref || env.LATEST_TAG }} + - name: Set lowercase username + run: echo "USERNAME=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV - # - 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: Extract version without 'v' + run: echo "VERSION=${{ github.event.release.tag_name }}" | sed 's/^v//' >> $GITHUB_ENV - # - name: Set lowercase username - # run: echo "USERNAME=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV + - 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: 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: Build the Docker image + run: docker build -t ghcr.io/${{ env.USERNAME }}/${{ github.event.repository.name }}/indy-node-monitor:${{ env.VERSION }} ./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 }} + - name: Push the Docker image + run: docker push ghcr.io/${{ env.USERNAME }}/${{ github.event.repository.name }}/indy-node-monitor:${{ env.VERSION }}