Skip to content

Commit 172bfaa

Browse files
authored
linkcheck-diff: Use git directly instead of 3rd party action (#3007)
1 parent 6a5df8f commit 172bfaa

File tree

1 file changed

+34
-31
lines changed

1 file changed

+34
-31
lines changed

.github/workflows/CI.yml

+34-31
Original file line numberDiff line numberDiff line change
@@ -88,37 +88,40 @@ jobs:
8888
run: |
8989
sphinx-build -D language=es -b html . _build/html
9090
91-
#link-check-diff:
92-
# # This job is sourced from https://github.com/aiven/devportal/blob/main/.github/workflows/linkcheck-changed-files.yaml
93-
# # It is CC 4.0 I licensed: https://creativecommons.org/licenses/by/4.0/
94-
# # Changes have been made.
95-
# runs-on: ubuntu-22.04
96-
# steps:
97-
# - uses: actions/checkout@v4
98-
# with:
99-
# fetch-depth: 0
100-
# - name: Get changed files
101-
# id: changed-files
102-
# uses: tj-actions/changed-files@v41
103-
# - uses: actions/setup-python@v5
104-
# with:
105-
# python-version: 3.9
106-
# - name: Install Dependencies
107-
# run: pip install -r source/requirements.txt
108-
# - name: Run linkcheck on .rst files
109-
# run: |
110-
# for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
111-
# if [ "${file: -4}" == ".rst" ]
112-
# then
113-
# var="$var $file"
114-
# fi
115-
# done
116-
# if [ -z "$var" ]
117-
# then
118-
# echo "No *.rst changed files to check."
119-
# else
120-
# make BUILDER_ARGS="$var" linkcheck
121-
# fi
91+
link-check-diff:
92+
runs-on: ubuntu-22.04
93+
steps:
94+
- uses: actions/checkout@v4
95+
with:
96+
fetch-depth: 0
97+
- name: Get changed files using git (comparing with main)
98+
id: changed-files
99+
run: |
100+
# Ensure the main branch is fetched
101+
git fetch origin main
102+
base_ref="origin/main"
103+
echo "Using base ref: ${base_ref}"
104+
changed_files=$(git diff --name-only "$base_ref" HEAD)
105+
echo "Changed files: $changed_files"
106+
# Set the output variable using the new GITHUB_OUTPUT file method
107+
echo "all_changed_files=$changed_files" >> $GITHUB_OUTPUT
108+
- uses: actions/setup-python@v5
109+
with:
110+
python-version: 3.9
111+
- name: Install Dependencies
112+
run: pip install -r source/requirements.txt
113+
- name: Run linkcheck on .rst files
114+
run: |
115+
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
116+
if [ "${file: -4}" == ".rst" ]; then
117+
var="$var $file"
118+
fi
119+
done
120+
if [ -z "$var" ]; then
121+
echo "No *.rst changed files to check."
122+
else
123+
make BUILDER_ARGS="$var" linkcheck
124+
fi
122125
123126
check-linting:
124127
runs-on: ubuntu-22.04

0 commit comments

Comments
 (0)