Skip to content

Update link_checkPR.yml #3109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/StalePRs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ jobs:
const STALE_CLOSE_THRESHOLD_MS = 1000 * 60 * 60 * 24 * 30;

const STALE_MESSAGE =
"Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as `Stale`. <br>" +
"Feel free to remove the `Stale` label if you feel this was a mistake. <br>" +
"If you are unable to remove the `Stale` label please contact a maintainer in order to do so. <br>" +
"Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as `stale`. <br>" +
"Feel free to remove the `stale` label if you feel this was a mistake. <br>" +
"If you are unable to remove the `stale` label please contact a maintainer in order to do so. <br>" +
"If you want the bot to never mark this PR stale again, add the `no-stale` label.<br>" +
"`Stale` pull requests will automatically be closed after 30 days of inactivity.<br>";
"`stale` pull requests will automatically be closed after 30 days of inactivity.<br>";

let numAPIRequests = 0;
let numProcessed = 0;
Expand All @@ -79,7 +79,7 @@ jobs:

// Check if the PR is stale, according to our configured thresholds.
let staleThresholdMillis;
if (labels.includes("Stale")) {
if (labels.includes("stale")) {
core.info(`[${pull.number}] PR is labeled stale, checking whether we should close it.`);
staleThresholdMillis = STALE_CLOSE_THRESHOLD_MS;
} else {
Expand All @@ -97,7 +97,7 @@ jobs:

// At this point, we know we should do something.
// For PRs already labeled stale, close them.
if (labels.includes("Stale")) {
if (labels.includes("stale")) {
core.info(`[${pull.number}] Closing PR.`);
numAPIRequests += 1;
await github.rest.issues.update({
Expand All @@ -123,7 +123,7 @@ jobs:
owner: "pytorch",
repo: "tutorials",
issue_number: pull.number,
labels: ["Stale"],
labels: ["stale"],
});
}
}
Expand Down
51 changes: 9 additions & 42 deletions .github/workflows/link_checkPR.yml
Original file line number Diff line number Diff line change
@@ -1,59 +1,26 @@
#Checks links in a PR to ensure they are valid. If link is valid but failing, it can be added to the .lycheeignore file
#Code source: https://github.com/lycheeverse/lychee-action/issues/238

name: link check on PR

on:
pull_request:
branches: [main]

jobs:
check-links:
linkChecker:
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}

- name: Check out main branch
run: git checkout main

- name: Dump all links from main
id: dump_links_from_main
fetch-depth: 1
- name: Get Changed Files
id: changed-files
uses: tj-actions/changed-files@v34
- name: Check Links
uses: lycheeverse/lychee-action@v1
with:
args: |
--dump
--include-fragments
.
output: ./links-main.txt

- name: Stash untracked files
run: git stash push --include-untracked

- name: Check out feature branch
run: git checkout ${{ github.head_ref }}

- name: Apply stashed changes
# Apply stashed changes, ignore errors if stash is empty
run: git stash pop || true

- name: Append links-main.txt to .lycheeignore
run: cat links-main.txt >> .lycheeignore

- name: Check links
uses: lycheeverse/lychee-action@v1
with:
args: |
--no-progress
--include-fragments
.
# Fail action on broken links
args: --accept=200,403,429 --base . --verbose --no-progress ${{ steps.changed-files.outputs.all_changed_files }}
token: ${{ secrets.CUSTOM_TOKEN }}
fail: true

- name: Suggestions
if: failure()
run: |
Expand Down
Loading