11name : Link Checker
22
33on :
4- schedule :
5- - cron : ' 0 6 * * 1'
6- workflow_dispatch :
7-
4+ schedule :
5+ - cron : ' 0 6 * * 1'
6+ workflow_dispatch :
7+
88permissions :
9- contents : read
10- pull-requests : write
11- issues : write
9+ contents : read
10+ pull-requests : write
11+ issues : write
1212
1313jobs :
1414 link-check :
15+ name : Run Link Check
1516 runs-on : ubuntu-latest
17+ strategy :
18+ fail-fast : false
19+ matrix :
20+ branch : [develop, release/y2025]
1621
1722 steps :
1823 - name : Checkout repository
1924 uses : actions/checkout@v3
25+ with :
26+ ref : ${{ matrix.branch }}
2027
2128 - name : Setup Node.js
2229 uses : actions/setup-node@v3
@@ -33,16 +40,36 @@ jobs:
3340 cd broken-links-script
3441 npm test
3542
43+ - name : Determine label based on branch
44+ if : always()
45+ id : label
46+ env :
47+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
48+ GH_REPO : ${{ github.repository }}
49+ run : |
50+ LABEL_NAME="broken-link-${{ matrix.branch }}"
51+ if gh api "repos/$GH_REPO/labels/$LABEL_NAME" &>/dev/null; then
52+ echo "Label ${LABEL_NAME} already exists"
53+ else
54+ echo "Creating label ${LABEL_NAME}"
55+ gh label create "${LABEL_NAME}" \
56+ --description "Indicates broken links in branch ${{ matrix.branch }}"
57+ fi
58+ echo "label=$LABEL_NAME" >> $GITHUB_OUTPUT
59+
3660 - name : Create GitHub issue if tests fail
3761 if : failure()
3862 env :
3963 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
4064 run : |
65+ label="${{ steps.label.outputs.label }}"
66+ branch_name="${{ matrix.branch }}"
67+ echo "Creating issue for branch: ${branch_name} with label: ${label}"
68+
4169 issue_url=$(gh issue create \
42- --title "Weekly Link Check Failed" \
70+ --title "Weekly Link Check Failed for ${branch_name} " \
4371 --body "Broken links detected in workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
44- --label "broken-link " \
72+ --label "${label} " \
4573 --assignee "BeateRixen")
4674
47- echo "Result: ${issue_url}"
48- echo "issue_created=${issue_url}" >> $GITHUB_OUTPUT
75+ echo "Result: ${issue_url}"
0 commit comments