Skip to content

Commit

Permalink
Simplify changed files check
Browse files Browse the repository at this point in the history
  • Loading branch information
SleeplessByte committed Jul 29, 2024
1 parent 3710dfc commit 0ac1cc0
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions .github/workflows/pr.ci.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ jobs:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
- name: Checkout PR
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
- name: Get changed files
Expand All @@ -21,8 +22,6 @@ jobs:
else
echo "changed_files=$(git diff --name-only --diff-filter=ACM ${{ github.event.before }} ${{ github.event.after }} | xargs)" >> $GITHUB_OUTPUT
fi
- name: Checkout PR
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: Use Node.js LTS (20.x)
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
Expand All @@ -45,6 +44,16 @@ jobs:
steps:
- name: Checkout PR
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
- name: Get changed files
id: changed-files
run: |
if ${{ github.event_name == 'pull_request' }}; then
echo "changed_files=$(git diff --name-only --diff-filter=ACM -r HEAD^1 HEAD | xargs)" >> $GITHUB_OUTPUT
else
echo "changed_files=$(git diff --name-only --diff-filter=ACM ${{ github.event.before }} ${{ github.event.after }} | xargs)" >> $GITHUB_OUTPUT
fi
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
Expand All @@ -55,11 +64,7 @@ jobs:
run: yarn install --immutable

- name: Run exercism/typescript ci (runs tests) for changed/added exercises
run: |
PULL_REQUEST_URL=$(jq -r ".pull_request.url" "$GITHUB_EVENT_PATH")
curl --url $"${PULL_REQUEST_URL}/files?per_page=100" --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | \
jq -c '.[] | select(.status == "added" or .status == "modified") | select(.filename | match("\\.(js|jsx|ts|tsx|md|json)$")) | .filename' | \
xargs -r yarn node scripts/pr.mjs
run: yarn node scripts/pr.mjs ${{ steps.changed-files.outputs.changed_files }}

impersonate:
# This job tries to run tests for the 'hello-world' exercise, but
Expand Down

0 comments on commit 0ac1cc0

Please sign in to comment.