-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci[pr-check-links]: add checks for modified and renamed anchors
- Loading branch information
Showing
1 changed file
with
52 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,20 +11,34 @@ jobs: | |
- name: Clone repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
repository: ${{ github.event.pull_request.head.repo.full_name }} | ||
fetch-depth: 0 | ||
|
||
- name: Set environment variables | ||
id: set-env | ||
run: | | ||
# Extract the base commit ID where the feature branch diverged from main | ||
base_commit=$(git merge-base origin/main ${{ github.event.pull_request.head.ref }}) | ||
echo "base_commit=$base_commit" >> $GITHUB_ENV | ||
# Extract the head commit ID on the feature branch | ||
head_commit=${{ github.event.pull_request.head.sha }} | ||
echo "head_commit=$head_commit" >> $GITHUB_ENV | ||
- name: Print commit IDs | ||
run: | | ||
echo ${{ env.base_commit }} | ||
echo $(git merge-base origin/main ${{ github.event.pull_request.head.ref }}) | ||
echo ${{ env.head_commit }} | ||
- name: Create baseline branch by reverting feature branch changes | ||
run: | | ||
# Create a copy of the feature branch | ||
git checkout -b baseline-copy | ||
# Find the base commit where the feature branch diverged from main | ||
base_commit=$(git merge-base origin/main baseline-copy) | ||
# Reset the new branch to the base commit | ||
git reset --hard $base_commit | ||
git reset --hard ${{ env.base_commit }} | ||
- name: Dump all links from baseline-copy | ||
uses: lycheeverse/[email protected] | ||
|
@@ -46,6 +60,39 @@ jobs: | |
- name: Print .lycheeignore | ||
run: cat .lycheeignore | ||
|
||
- name: Print commit IDs | ||
run: | | ||
echo ${{ env.base_commit }} | ||
echo ${{ env.head_commit }} | ||
- name: Dump names of files altered in PR and add prefix to each file | ||
run: | | ||
git diff --name-only --diff-filter=DM ${{ env.base_commit }} ${{ env.head_commit }} > altered-files.txt | ||
sed -i 's|$|#|' altered-files.txt | ||
git diff --name-status --diff-filter=R ${{ env.base_commit }} ${{ env.head_commit }} | awk '{print $2}' > renamed-files.txt | ||
sed -i 's|$|#|' renamed-files.txt | ||
- name: Print altered-files.txt | ||
run: cat altered-files.txt | ||
|
||
- name: Print renamed-files.txt | ||
run: cat renamed-files.txt | ||
|
||
- name: Remove links to altered files in .lycheeignore | ||
run: | | ||
while IFS= read -r line; do | ||
sed -i "\|$line|d" .lycheeignore | ||
done < altered-files.txt | ||
- name: Remove links to altered files in .lycheeignore | ||
run: | | ||
while IFS= read -r line; do | ||
sed -i "\|$line|d" .lycheeignore | ||
done < renamed-files.txt | ||
- name: Print .lycheeignore | ||
run: cat .lycheeignore | ||
|
||
- name: Check links | ||
uses: lycheeverse/[email protected] | ||
with: | ||
|