Skip to content

Commit a6a74ef

Browse files
committed
Play around with commands
1 parent 973699c commit a6a74ef

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

Diff for: .github/workflows/ci.yml

+14-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,18 @@ jobs:
1515
# https://github.com/crazy-max/ghaction-github-pages/issues/1#issuecomment-623202206
1616
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1717
steps:
18-
- uses: actions/checkout@v2
18+
- uses: actions/checkout@v3
19+
with:
20+
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
21+
- name: Get changed files
22+
id: changed-files
23+
# source: https://stackoverflow.com/a/74268200
24+
run: |
25+
if ${{ github.event_name == 'pull_request' }}; then
26+
echo "changed_files=$(git diff --name-only -r HEAD^1 HEAD | xargs)" >> $GITHUB_OUTPUT
27+
else
28+
echo "changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | xargs)" >> $GITHUB_OUTPUT
29+
fi
1930
- name: Lint
2031
uses: avto-dev/markdown-lint@v1
2132
with:
@@ -25,8 +36,8 @@ jobs:
2536
run: |
2637
npm install -g @umbrelladocs/linkspector
2738
echo "linkspector version: $(linkspector --version)"
28-
echo "Files changed in this pr: $(git diff --name-only ${{ github.event.before }} ${{ github.sha }})"
29-
linkspector check $(git diff --name-only ${{ github.event.before }} ${{ github.sha }})
39+
echo "Files changed in this pr: ${{ steps.changed-files.outputs.changed_files }}"
40+
linkspector check ${{ steps.changed-files.outputs.changed_files }}
3041
- name: Install Zola
3142
run: curl -L ${BASE_URL}/${VERS}/zola-${VERS}-${ARCH}.tar.gz | tar -xz
3243
- run: ./zola --version

0 commit comments

Comments
 (0)