From 93ec8bb517de7e8cb31c4a83d4bfc6f4940b55da Mon Sep 17 00:00:00 2001 From: Krystof Woldrich <31292499+krystofwoldrich@users.noreply.github.com> Date: Thu, 4 Apr 2024 18:27:37 +0200 Subject: [PATCH] fix(ci): `diff_check` action should succeed on non-PR runs (#3742) * fix(ci): `diff_check` action should succeed on non-PR runs * test skipped steps * Revert "test skipped steps" This reverts commit ec059dd6612a830fc206b38ddcfb0587f830eacb. --- .github/workflows/skip-ci.yml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/skip-ci.yml b/.github/workflows/skip-ci.yml index 8a3b86c68..864003700 100644 --- a/.github/workflows/skip-ci.yml +++ b/.github/workflows/skip-ci.yml @@ -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))