Skip to content

Commit d4e7004

Browse files
authored
fixed the logic for issue creation (#360)
* fixed yml syntax in external-link file Signed-off-by: Rupam-It <mannarupam3@gmail.com> * Update external-link-check.yml Signed-off-by: Rupam Manna <111190901+Rupam-It@users.noreply.github.com> Signed-off-by: Rupam-It <mannarupam3@gmail.com> * change for .lycheecache Signed-off-by: Rupam-It <mannarupam3@gmail.com> * change the cache store logic Signed-off-by: Rupam-It <mannarupam3@gmail.com> * change the cache store logic 2 Signed-off-by: Rupam-It <mannarupam3@gmail.com> * change the cache store logic 3 Signed-off-by: Rupam-It <mannarupam3@gmail.com> * change the cache store logic 4 Signed-off-by: Rupam-It <mannarupam3@gmail.com> * change the cache store logic 5 Signed-off-by: Rupam-It <mannarupam3@gmail.com> * change the cache store logic 6 Signed-off-by: Rupam-It <mannarupam3@gmail.com> * remove cache and conflict Signed-off-by: Rupam-It <mannarupam3@gmail.com> * remove cache and conflict 2 Signed-off-by: Rupam-It <mannarupam3@gmail.com> * remove cache and conflict 2 Signed-off-by: Rupam-It <mannarupam3@gmail.com> * Updated link check workflow (removed cache) Signed-off-by: Rupam-It <mannarupam3@gmail.com> * Updated link check workflow (removed cache) Signed-off-by: Rupam-It <mannarupam3@gmail.com> * all updated Signed-off-by: Rupam-It <mannarupam3@gmail.com> * checking the external link Signed-off-by: Rupam-It <mannarupam3@gmail.com> * checking the external link 2 Signed-off-by: Rupam-It <mannarupam3@gmail.com> * checking the external link 3 Signed-off-by: Rupam-It <mannarupam3@gmail.com> * checking the external link 4 Signed-off-by: Rupam-It <mannarupam3@gmail.com> * checking the external link 4 Signed-off-by: Rupam-It <mannarupam3@gmail.com> * checking the external link 5 Signed-off-by: Rupam-It <mannarupam3@gmail.com> * checking the external link 6 Signed-off-by: Rupam-It <mannarupam3@gmail.com> * checking the external link 7 Signed-off-by: Rupam-It <mannarupam3@gmail.com> * checking the external link 7 Signed-off-by: Rupam-It <mannarupam3@gmail.com> * checking the external link 8 Signed-off-by: Rupam-It <mannarupam3@gmail.com> * fixed the logic for issue creation ! Signed-off-by: Rupam-It <mannarupam3@gmail.com> * fix issue339 Signed-off-by: Rupam-It <mannarupam3@gmail.com> * fix issue339 1 Signed-off-by: Rupam-It <mannarupam3@gmail.com> * fix issue339 2 Signed-off-by: Rupam-It <mannarupam3@gmail.com> * fix issue339 3 Signed-off-by: Rupam-It <mannarupam3@gmail.com> * fix issue339 4 Signed-off-by: Rupam-It <mannarupam3@gmail.com> * the manual trigger part is updated Signed-off-by: Rupam Manna <111190901+Rupam-It@users.noreply.github.com> --------- Signed-off-by: Rupam-It <mannarupam3@gmail.com> Signed-off-by: Rupam Manna <111190901+Rupam-It@users.noreply.github.com>
1 parent 7880193 commit d4e7004

File tree

1 file changed

+49
-23
lines changed

1 file changed

+49
-23
lines changed
Lines changed: 49 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,93 @@
11
# This link checks Microcks website links in Markdown HTML files once per day
22
# from: https://github.com/lycheeverse/lychee-action
33
# link checker used is 'lychee': https://github.com/lycheeverse/lychee
4-
54
name: External Link Check
5+
66
on:
7-
# This event will only trigger a workflow run if the workflow file is on the default branch.
8-
# ucomment the following line if you want to run the workflow manually
9-
# workflow_dispatch:
10-
# Run once a week on Sunday at 00h42 UTC (0:42 AM UTC aka 1:42 AM CEST with daylight saving time)
117
schedule:
12-
- cron: "42 0 * * 0"
8+
- cron: "42 0 * * 0" # This will run the workflow every Sunday at 00:42 UTC
9+
workflow_dispatch: # This allows the workflow to be triggered manually
1310

1411
jobs:
1512
linkChecker:
1613
runs-on: ubuntu-latest
14+
1715
steps:
1816
- name: Checkout repository
19-
uses: actions/checkout@v4
2017

21-
# Link Checker run with lychee action
18+
uses: actions/checkout@v4
19+
20+
- name: Ensure Report Directory Exists
21+
run: mkdir -p link-checker
22+
23+
# Run lychee and capture errors
24+
2225
- name: Link Checker
2326
id: lychee
2427
uses: lycheeverse/lychee-action@v1
28+
continue-on-error: true
2529
with:
2630
# Check all markdown and html files in repo
2731
# Exclude all files except those starting with http:// or https:// thanks to the --scheme option
28-
# Use cache but cache the results for 8 hours
29-
args: --base public --verbose --no-progress './**/*.md' './**/*.html' --scheme https --scheme http --cache --max-cache-age 8h
32+
args: --verbose --no-progress './**/*.md' './**/*.html' --scheme https --scheme http
3033
# Use markdown as output format
3134
format: markdown
3235
# Use different output file path
3336
output: ./link-checker/report.md
34-
# Use a custom GitHub token to "avoid" rate limiting
35-
token: ${{ secrets.CUSTOM_TOKEN }}
3637
# Don't fail action on broken links
3738
fail: false
39+
env:
40+
# Use a custom GitHub token to "avoid" rate limiting
41+
GITHUB_TOKEN: ${{ secrets.CUSTOM_TOKEN }}
3842

39-
# Format the date for the issue title and store it in an environment variable
43+
# Capture lychee output including regex errors
44+
- name: Capture Errors
45+
run: |
46+
echo "### Lychee Link Check Report" > ./link-checker/report.md
47+
echo "" >> ./link-checker/report.md
48+
{ lychee --verbose --no-progress './**/*.md' './**/*.html' --scheme https --scheme http; } >> ./link-checker/report.md 2>&1 || true
49+
echo "" >> ./link-checker/report.md
50+
51+
# Debug: Show report contents
52+
- name: Debug Report
53+
run: cat ./link-checker/report.md
54+
55+
# Check if report contains regex errors or broken links
56+
- name: Check for Errors
57+
id: check_errors
58+
run: |
59+
if grep -q "Error:" ./link-checker/report.md || grep -q "✗" ./link-checker/report.md; then
60+
echo "has_errors=true" >> $GITHUB_ENV
61+
else
62+
echo "has_errors=false" >> $GITHUB_ENV
63+
fi
64+
65+
# Format the date for the issue title and store it in an environment variable
4066
- name: Format Date
41-
id: format_date
4267
run: echo "DATE=$(date +'%A, %e. %b %Y')" >> $GITHUB_ENV
43-
44-
# Create an issue if there are broken links
68+
69+
# Create an issue if there are broken links
4570
- name: Create Issue From File
46-
if: env.lychee_exit_code == 1
47-
id: create_issue
71+
if: env.has_errors == 'true'
72+
id: create_issue # 🔹 Add an ID to reference outputs later
4873
uses: peter-evans/create-issue-from-file@v5
4974
with:
5075
title: "External Link Check Report - ${{ env.DATE }}"
5176
content-filepath: ./link-checker/report.md
5277
labels: report, automated issue, contribution message, help wanted
53-
78+
5479
# Store the issue number in an environment variable
5580
- name: Store Issue Number
56-
if: steps.create_issue.outputs.issue-number
81+
if: steps.create_issue.outputs.issue-number != ''
5782
run: echo "ISSUE_NUMBER=${{ steps.create_issue.outputs.issue-number }}" >> $GITHUB_ENV
58-
83+
5984
# Add a comment to the issue with the contribution message
6085
- name: Add contribution message as new comment
61-
if: ${{ env.ISSUE_NUMBER }}
86+
87+
if: env.ISSUE_NUMBER != ''
88+
6289
run: gh issue comment "$ISSUE_NUMBER" --body-file "$BODY"
6390
env:
6491
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6592
GH_REPO: ${{ github.repository }}
66-
NUMBER: ${{ env.ISSUE_NUMBER }}
6793
BODY: "./.github/contribution_message.md"

0 commit comments

Comments
 (0)