Skip to content

Commit

Permalink
fix: dump links from baseline commit for pr link checking
Browse files Browse the repository at this point in the history
  • Loading branch information
f-hollow committed Oct 31, 2024
1 parent ba6989d commit bf5b107
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions .github/workflows/pr-check-links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,27 @@ 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: Fetch all branches
run: git fetch --all

- name: Create baseline branch by reverting feature branch changes
run: |
# Create a copy of the feature branch
git checkout -b baseline-copy
# git checkout ${{ github.event.pull_request.head.sha }}
# Find the base commit where the feature branch diverged from main
base_commit=$(git merge-base origin/main baseline-copy)
- name: Check out main branch
run: git checkout main
# Reset the new branch to the base commit
git reset --hard $base_commit
- name: Dump all links from main
id: dump_links_from_main
- name: Dump all links from baseline-copy
uses: lycheeverse/[email protected]
with:
args: |
Expand All @@ -28,10 +40,10 @@ jobs:
--exclude-path ./themes/
--exclude-path ./layouts/
.
output: ./links-main.txt
output: ./links-baseline.txt

- name: Print links-main.txt in main
run: cat links-main.txt
- name: Print links-baseline.txt
run: cat links-baseline.txt

- name: Stash untracked files
run: git stash push --include-untracked
Expand All @@ -43,8 +55,8 @@ jobs:
# 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: Append links-baseline.txt to .lycheeignore
run: cat links-baseline.txt >> .lycheeignore

- name: Check .lycheeignore content
run: cat .lycheeignore
Expand Down

0 comments on commit bf5b107

Please sign in to comment.