Skip to content

Commit 18abd43

Browse files
authored
Update link_checkPR.yml (#3109)
* Update link_checkPR.yml * Update StalePRs.yml
1 parent f2b930e commit 18abd43

File tree

2 files changed

+16
-49
lines changed

2 files changed

+16
-49
lines changed

.github/workflows/StalePRs.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ jobs:
5757
const STALE_CLOSE_THRESHOLD_MS = 1000 * 60 * 60 * 24 * 30;
5858
5959
const STALE_MESSAGE =
60-
"Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as `Stale`. <br>" +
61-
"Feel free to remove the `Stale` label if you feel this was a mistake. <br>" +
62-
"If you are unable to remove the `Stale` label please contact a maintainer in order to do so. <br>" +
60+
"Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as `stale`. <br>" +
61+
"Feel free to remove the `stale` label if you feel this was a mistake. <br>" +
62+
"If you are unable to remove the `stale` label please contact a maintainer in order to do so. <br>" +
6363
"If you want the bot to never mark this PR stale again, add the `no-stale` label.<br>" +
64-
"`Stale` pull requests will automatically be closed after 30 days of inactivity.<br>";
64+
"`stale` pull requests will automatically be closed after 30 days of inactivity.<br>";
6565
6666
let numAPIRequests = 0;
6767
let numProcessed = 0;
@@ -79,7 +79,7 @@ jobs:
7979
8080
// Check if the PR is stale, according to our configured thresholds.
8181
let staleThresholdMillis;
82-
if (labels.includes("Stale")) {
82+
if (labels.includes("stale")) {
8383
core.info(`[${pull.number}] PR is labeled stale, checking whether we should close it.`);
8484
staleThresholdMillis = STALE_CLOSE_THRESHOLD_MS;
8585
} else {
@@ -97,7 +97,7 @@ jobs:
9797
9898
// At this point, we know we should do something.
9999
// For PRs already labeled stale, close them.
100-
if (labels.includes("Stale")) {
100+
if (labels.includes("stale")) {
101101
core.info(`[${pull.number}] Closing PR.`);
102102
numAPIRequests += 1;
103103
await github.rest.issues.update({
@@ -123,7 +123,7 @@ jobs:
123123
owner: "pytorch",
124124
repo: "tutorials",
125125
issue_number: pull.number,
126-
labels: ["Stale"],
126+
labels: ["stale"],
127127
});
128128
}
129129
}

.github/workflows/link_checkPR.yml

Lines changed: 9 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,26 @@
11
#Checks links in a PR to ensure they are valid. If link is valid but failing, it can be added to the .lycheeignore file
2-
#Code source: https://github.com/lycheeverse/lychee-action/issues/238
32

43
name: link check on PR
54

65
on:
76
pull_request:
87
branches: [main]
9-
108
jobs:
11-
check-links:
9+
linkChecker:
1210
runs-on: ubuntu-latest
1311
steps:
14-
- name: Clone repository
15-
uses: actions/checkout@v4
12+
- uses: actions/checkout@v4
1613
with:
17-
fetch-depth: 0
18-
ref: ${{github.event.pull_request.head.ref}}
19-
repository: ${{github.event.pull_request.head.repo.full_name}}
20-
21-
- name: Check out main branch
22-
run: git checkout main
23-
24-
- name: Dump all links from main
25-
id: dump_links_from_main
14+
fetch-depth: 1
15+
- name: Get Changed Files
16+
id: changed-files
17+
uses: tj-actions/changed-files@v34
18+
- name: Check Links
2619
uses: lycheeverse/lychee-action@v1
2720
with:
28-
args: |
29-
--dump
30-
--include-fragments
31-
.
32-
output: ./links-main.txt
33-
34-
- name: Stash untracked files
35-
run: git stash push --include-untracked
36-
37-
- name: Check out feature branch
38-
run: git checkout ${{ github.head_ref }}
39-
40-
- name: Apply stashed changes
41-
# Apply stashed changes, ignore errors if stash is empty
42-
run: git stash pop || true
43-
44-
- name: Append links-main.txt to .lycheeignore
45-
run: cat links-main.txt >> .lycheeignore
46-
47-
- name: Check links
48-
uses: lycheeverse/lychee-action@v1
49-
with:
50-
args: |
51-
--no-progress
52-
--include-fragments
53-
.
54-
# Fail action on broken links
21+
args: --accept=200,403,429 --base . --verbose --no-progress ${{ steps.changed-files.outputs.all_changed_files }}
22+
token: ${{ secrets.CUSTOM_TOKEN }}
5523
fail: true
56-
5724
- name: Suggestions
5825
if: failure()
5926
run: |

0 commit comments

Comments
 (0)