From cb4037acc6f184045e9c258e194a16782ad4f4a3 Mon Sep 17 00:00:00 2001 From: Edoardo Zoni Date: Mon, 18 Nov 2024 13:38:52 -0800 Subject: [PATCH] Add workflow to check files changed --- .github/workflows/check_diff.yml | 49 ++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/check_diff.yml diff --git a/.github/workflows/check_diff.yml b/.github/workflows/check_diff.yml new file mode 100644 index 00000000000..c4ef1c08fe8 --- /dev/null +++ b/.github/workflows/check_diff.yml @@ -0,0 +1,49 @@ +name: PR analysis + +on: + pull_request: + +concurrency: + group: ${{ github.ref }}-${{ github.head_ref }}-checkdiff + cancel-in-progress: true + +jobs: + check_diff: + name: Check files changed + runs-on: ubuntu-20.04 + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Define base and head refs + env: + BASE_REF: ${{ github.event.pull_request.base.ref }} + HEAD_REF: ${{ github.event.pull_request.head.ref }} + run: | + echo "Base ref: ${BASE_REF}" + echo "Head ref: ${HEAD_REF}" + - name: Add forked repository as remote + run: | + git remote add fork ${{ github.event.pull_request.head.repo.clone_url }} + - name: Fetch base branch from main repository + run: | + git fetch origin ${BASE_REF} + - name: Fetch head branch from forked repository + run: | + git fetch fork ${HEAD_REF} + - name: Get files changed + env: + BASE_REF: ${{ github.event.pull_request.base.ref }} + HEAD_REF: ${{ github.event.pull_request.head.ref }} + run: | + git diff --name-only --diff-filter=ACMRTUXB origin/${BASE_REF}..fork/${HEAD_REF} > check_diff.txt + - name: Check files changed + run: | + if grep -v -E "^(docs|\.github)/|\.azure-pipelines\.yml$" check_diff.txt; then + echo "skip=false" >> ${GITHUB_OUTPUT} + else + echo "skip=true" >> ${GITHUB_OUTPUT} + fi + outputs: + skip: ${{ steps.check.outputs.skip }}