From ef018f43ade9428b505b92ef3ca88ea309a95857 Mon Sep 17 00:00:00 2001 From: logu1411 Date: Tue, 11 Nov 2025 16:14:50 +0100 Subject: [PATCH 01/10] Update workflow to run on develop and release2025 branch --- .github/workflows/link-checker.yml | 69 +++++++++++++++++++++++++----- 1 file changed, 59 insertions(+), 10 deletions(-) diff --git a/.github/workflows/link-checker.yml b/.github/workflows/link-checker.yml index d7a0ba3acb..3e3a0deaf4 100644 --- a/.github/workflows/link-checker.yml +++ b/.github/workflows/link-checker.yml @@ -1,17 +1,52 @@ name: Link Checker on: - schedule: - - cron: '0 6 * * 1' - workflow_dispatch: - + schedule: + - cron: '0 6 * * 1' + workflow_dispatch: + inputs: + dispatcher: + description: 'Dispatch link checker for monitored branches? (true/false)' + required: true + default: 'false' + permissions: - contents: read - pull-requests: write - issues: write + contents: read + pull-requests: write + issues: write + +env: + MONITORED_BRANCHES: 'develop,release/y2025' jobs: + dispatch-for-selected-branches: + name: Run Link Checker for selected branches + if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' && inputs.dispatcher == 'true' }} + runs-on: ubuntu-latest + + steps: + - name: Generate token for GH CLI + uses: actions/create-github-app-token@v2 + id: linkcheck-token + with: + app-id: ${{ vars.LINKCHECK_APP_ID }} + private-key: ${{ secrets.LINKCHECK_PRIVATE_KEY }} + + - name: Dispatch link check for selected branches + env: + GH_TOKEN: ${{ steps.linkcheck-token.outputs.token }} + REPO: ${{ github.repository }} + run: | + IFS=',' read -ra branches <<< "$MONITORED_BRANCHES" + for branch in "${branches[@]}"; do + echo "Triggering Link Checker workflow for branch: $branch" + gh workflow run link-checker.yml --ref "$branch" -f dispatcher "false" + sleep 30 + done + link-check: + name: Run Link Check + if: ${{ github.event_name == 'workflow_dispatch' && inputs.dispatcher == 'false' }} runs-on: ubuntu-latest steps: @@ -33,16 +68,30 @@ jobs: cd broken-links-script npm test + - name: Determine label based on branch + if: always() + id: label + run: | + LABEL_NAME="broken-link-${GITHUB_REF_NAME}" + if ! gh label list | grep -q "^${LABEL_NAME}\b"; then + gh label create "${LABEL_NAME}" --description "Indicates broken links in branch ${GITHUB_REF_NAME}" + fi + echo "label=$LABEL_NAME" >> $GITHUB_OUTPUT + - name: Create GitHub issue if tests fail if: failure() env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | + branch_name="${GITHUB_REF_NAME}" + label="${{ steps.label.outputs.label }}" + echo "Creating issue for branch: ${branch_name} with label: ${label}" + issue_url=$(gh issue create \ - --title "Weekly Link Check Failed" \ + --title "Weekly Link Check Failed for ${branch_name}" \ --body "Broken links detected in workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \ - --label "broken-link" \ + --label "${label}" \ --assignee "BeateRixen") echo "Result: ${issue_url}" - echo "issue_created=${issue_url}" >> $GITHUB_OUTPUT + echo "issue_created=${issue_url}" >> $GITHUB_OUTPUT \ No newline at end of file From e8ee61d02cb04de95e3fb4264167c6a981f79496 Mon Sep 17 00:00:00 2001 From: logu1411 Date: Mon, 17 Nov 2025 10:00:40 +0100 Subject: [PATCH 02/10] Added App ID and private key in the link checker workflow --- .github/workflows/link-checker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/link-checker.yml b/.github/workflows/link-checker.yml index 3e3a0deaf4..a77e160167 100644 --- a/.github/workflows/link-checker.yml +++ b/.github/workflows/link-checker.yml @@ -29,8 +29,8 @@ jobs: uses: actions/create-github-app-token@v2 id: linkcheck-token with: - app-id: ${{ vars.LINKCHECK_APP_ID }} - private-key: ${{ secrets.LINKCHECK_PRIVATE_KEY }} + app-id: ${{ vars.DOCS_LINK_CHECK_APP_ID }} + private-key: ${{ secrets.DOCS_LINK_CHECK_APP_KEY }} - name: Dispatch link check for selected branches env: From 4ee0fef84251566eee4cc58adb2095f72b3335d8 Mon Sep 17 00:00:00 2001 From: logu1411 Date: Mon, 17 Nov 2025 10:05:17 +0100 Subject: [PATCH 03/10] Added a step name to checkout repository --- .github/workflows/link-checker.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/link-checker.yml b/.github/workflows/link-checker.yml index a77e160167..1a0c6b2cf6 100644 --- a/.github/workflows/link-checker.yml +++ b/.github/workflows/link-checker.yml @@ -25,6 +25,9 @@ jobs: runs-on: ubuntu-latest steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Generate token for GH CLI uses: actions/create-github-app-token@v2 id: linkcheck-token From b50d7892d39be5e54a4b2099b6ddfdb98a6d2e02 Mon Sep 17 00:00:00 2001 From: logu1411 Date: Mon, 17 Nov 2025 10:08:20 +0100 Subject: [PATCH 04/10] Added equal sign when running link-checker --- .github/workflows/link-checker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/link-checker.yml b/.github/workflows/link-checker.yml index 1a0c6b2cf6..7e62c6df7a 100644 --- a/.github/workflows/link-checker.yml +++ b/.github/workflows/link-checker.yml @@ -27,7 +27,7 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v3 - + - name: Generate token for GH CLI uses: actions/create-github-app-token@v2 id: linkcheck-token @@ -43,7 +43,7 @@ jobs: IFS=',' read -ra branches <<< "$MONITORED_BRANCHES" for branch in "${branches[@]}"; do echo "Triggering Link Checker workflow for branch: $branch" - gh workflow run link-checker.yml --ref "$branch" -f dispatcher "false" + gh workflow run link-checker.yml --ref "$branch" -f dispatcher=false sleep 30 done From 6d19437194499519a6e6220a794832bece236ec4 Mon Sep 17 00:00:00 2001 From: logu1411 Date: Mon, 17 Nov 2025 10:14:17 +0100 Subject: [PATCH 05/10] Renamed link-check to link-checker --- .github/workflows/link-checker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/link-checker.yml b/.github/workflows/link-checker.yml index 7e62c6df7a..90bf75a63c 100644 --- a/.github/workflows/link-checker.yml +++ b/.github/workflows/link-checker.yml @@ -47,7 +47,7 @@ jobs: sleep 30 done - link-check: + link-checker: name: Run Link Check if: ${{ github.event_name == 'workflow_dispatch' && inputs.dispatcher == 'false' }} runs-on: ubuntu-latest From ccf8e26dddde093dd39e8acf85ae2c089e233f25 Mon Sep 17 00:00:00 2001 From: logu1411 Date: Mon, 17 Nov 2025 10:24:25 +0100 Subject: [PATCH 06/10] remove the dispatcher approach instead using matrix based approach --- .github/workflows/link-checker.yml | 51 +++++++----------------------- 1 file changed, 11 insertions(+), 40 deletions(-) diff --git a/.github/workflows/link-checker.yml b/.github/workflows/link-checker.yml index 90bf75a63c..8ba8aad685 100644 --- a/.github/workflows/link-checker.yml +++ b/.github/workflows/link-checker.yml @@ -4,11 +4,6 @@ on: schedule: - cron: '0 6 * * 1' workflow_dispatch: - inputs: - dispatcher: - description: 'Dispatch link checker for monitored branches? (true/false)' - required: true - default: 'false' permissions: contents: read @@ -19,42 +14,19 @@ env: MONITORED_BRANCHES: 'develop,release/y2025' jobs: - dispatch-for-selected-branches: - name: Run Link Checker for selected branches - if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' && inputs.dispatcher == 'true' }} - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Generate token for GH CLI - uses: actions/create-github-app-token@v2 - id: linkcheck-token - with: - app-id: ${{ vars.DOCS_LINK_CHECK_APP_ID }} - private-key: ${{ secrets.DOCS_LINK_CHECK_APP_KEY }} - - - name: Dispatch link check for selected branches - env: - GH_TOKEN: ${{ steps.linkcheck-token.outputs.token }} - REPO: ${{ github.repository }} - run: | - IFS=',' read -ra branches <<< "$MONITORED_BRANCHES" - for branch in "${branches[@]}"; do - echo "Triggering Link Checker workflow for branch: $branch" - gh workflow run link-checker.yml --ref "$branch" -f dispatcher=false - sleep 30 - done - - link-checker: + link-check: name: Run Link Check - if: ${{ github.event_name == 'workflow_dispatch' && inputs.dispatcher == 'false' }} runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + branch: [develop, release/y2025] steps: - name: Checkout repository uses: actions/checkout@v3 + with: + ref: ${{ matrix.branch }} - name: Setup Node.js uses: actions/setup-node@v3 @@ -75,9 +47,9 @@ jobs: if: always() id: label run: | - LABEL_NAME="broken-link-${GITHUB_REF_NAME}" + LABEL_NAME="broken-link-${{ matrix.branch }}" if ! gh label list | grep -q "^${LABEL_NAME}\b"; then - gh label create "${LABEL_NAME}" --description "Indicates broken links in branch ${GITHUB_REF_NAME}" + gh label create "${LABEL_NAME}" --description "Indicates broken links in branch ${{ matrix.branch }}" fi echo "label=$LABEL_NAME" >> $GITHUB_OUTPUT @@ -86,8 +58,8 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - branch_name="${GITHUB_REF_NAME}" label="${{ steps.label.outputs.label }}" + branch_name="${{ matrix.branch }}" echo "Creating issue for branch: ${branch_name} with label: ${label}" issue_url=$(gh issue create \ @@ -96,5 +68,4 @@ jobs: --label "${label}" \ --assignee "BeateRixen") - echo "Result: ${issue_url}" - echo "issue_created=${issue_url}" >> $GITHUB_OUTPUT \ No newline at end of file + echo "Result: ${issue_url}" \ No newline at end of file From 9da3aba681defdfaab54225da7ae14318628e0b6 Mon Sep 17 00:00:00 2001 From: logu1411 Date: Wed, 26 Nov 2025 09:51:31 +0100 Subject: [PATCH 07/10] Remove env monitoring steps from the link checker workflow --- .github/workflows/link-checker.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/link-checker.yml b/.github/workflows/link-checker.yml index 8ba8aad685..5d39907e4b 100644 --- a/.github/workflows/link-checker.yml +++ b/.github/workflows/link-checker.yml @@ -10,9 +10,6 @@ permissions: pull-requests: write issues: write -env: - MONITORED_BRANCHES: 'develop,release/y2025' - jobs: link-check: name: Run Link Check From 58674f3ad6da2d26f5f5abeeed34b90257f54ee0 Mon Sep 17 00:00:00 2001 From: logu1411 Date: Wed, 26 Nov 2025 16:21:51 +0100 Subject: [PATCH 08/10] update broken link script to check the existing labels --- .github/workflows/link-checker.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/link-checker.yml b/.github/workflows/link-checker.yml index 5d39907e4b..fcd6e20ffe 100644 --- a/.github/workflows/link-checker.yml +++ b/.github/workflows/link-checker.yml @@ -43,12 +43,18 @@ jobs: - name: Determine label based on branch if: always() id: label + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | LABEL_NAME="broken-link-${{ matrix.branch }}" - if ! gh label list | grep -q "^${LABEL_NAME}\b"; then - gh label create "${LABEL_NAME}" --description "Indicates broken links in branch ${{ matrix.branch }}" + if gh label list -L 1000 | grep -q "^${LABEL_NAME}\b"; then + echo "Label ${LABEL_NAME} already exists" + else + echo "Creating label ${LABEL_NAME}" + gh label create "${LABEL_NAME}" \ + --description "Indicates broken links in branch ${{ matrix.branch }}" fi - echo "label=$LABEL_NAME" >> $GITHUB_OUTPUT + echo "label=$LABEL_NAME" >> $GITHUB_OUTPU - name: Create GitHub issue if tests fail if: failure() From 270582aa9f8b5ea48e94c0c5b05aa3b3ee8438e8 Mon Sep 17 00:00:00 2001 From: Lokesh Guthi <183061238+logu-c8y@users.noreply.github.com> Date: Wed, 26 Nov 2025 16:47:22 +0100 Subject: [PATCH 09/10] correcting typo mistake MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Paweł Rynarzewski <92171763+pawel-rynarzewski-c8y@users.noreply.github.com> --- .github/workflows/link-checker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/link-checker.yml b/.github/workflows/link-checker.yml index fcd6e20ffe..b7ef5f5b18 100644 --- a/.github/workflows/link-checker.yml +++ b/.github/workflows/link-checker.yml @@ -54,7 +54,7 @@ jobs: gh label create "${LABEL_NAME}" \ --description "Indicates broken links in branch ${{ matrix.branch }}" fi - echo "label=$LABEL_NAME" >> $GITHUB_OUTPU + echo "label=$LABEL_NAME" >> $GITHUB_OUTPUT - name: Create GitHub issue if tests fail if: failure() From 0d8a21435d978d992618c48871a60a37e4ea4ce2 Mon Sep 17 00:00:00 2001 From: Lokesh Guthi <183061238+logu-c8y@users.noreply.github.com> Date: Wed, 26 Nov 2025 16:47:29 +0100 Subject: [PATCH 10/10] Update .github/workflows/link-checker.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Paweł Rynarzewski <92171763+pawel-rynarzewski-c8y@users.noreply.github.com> --- .github/workflows/link-checker.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/link-checker.yml b/.github/workflows/link-checker.yml index b7ef5f5b18..a9466ff668 100644 --- a/.github/workflows/link-checker.yml +++ b/.github/workflows/link-checker.yml @@ -45,9 +45,10 @@ jobs: id: label env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} run: | LABEL_NAME="broken-link-${{ matrix.branch }}" - if gh label list -L 1000 | grep -q "^${LABEL_NAME}\b"; then + if gh api "repos/$GH_REPO/labels/$LABEL_NAME" &>/dev/null; then echo "Label ${LABEL_NAME} already exists" else echo "Creating label ${LABEL_NAME}"