Skip to content

Commit

Permalink
fix(ci): diff_check action should succeed on non-PR runs (#3742)
Browse files Browse the repository at this point in the history
* fix(ci): `diff_check` action should succeed on non-PR runs

* test skipped steps

* Revert "test skipped steps"

This reverts commit ec059dd.
  • Loading branch information
krystofwoldrich committed Apr 4, 2024
1 parent 9d81b37 commit 93ec8bb
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions .github/workflows/skip-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,33 @@ jobs:
skip_ci:
${{ steps.check_diff.outputs.skip_ci }}
steps:
- name: Check if is PR
id: check-pr
run: |
if [ -z "${{ github.event.pull_request.number }}" ] || [ -z "${{ github.base_ref }}" ] || [ -z "${{ github.head_ref }}" ]; then
echo "This action is intended to be run on pull requests only."
echo "is-pr=false" >> $GITHUB_OUTPUT
else
echo "is-pr=true" >> $GITHUB_OUTPUT
fi
- name: Checkout PR Base Branch
if: steps.check-pr.outputs.is-pr == 'true'
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.base_ref }}

- name: Checkout PR Head Branch
if: steps.check-pr.outputs.is-pr == 'true'
run: |
git fetch origin pull/${{ github.event.pull_request.number }}/head:${{ github.head_ref }}
git checkout ${{ github.head_ref }}
- name: Check diff from Pull Request
if: steps.check-pr.outputs.is-pr == 'true'
id: check_diff
run: |
if [ -z "${{ github.base_ref }}" ] || [ -z "${{ github.head_ref }}" ]; then
echo "This action is intended to be run on pull requests only."
exit 0
fi
skipList=(".github/CODEOWNERS" ".prettierignore")
# Ignores changelog.md, readme.md,...
fileChangesArray=($(git diff --name-only ${{ github.base_ref }}...${{ github.head_ref }} | grep -v '\.md$' || true))
Expand Down

0 comments on commit 93ec8bb

Please sign in to comment.