mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-10-14 18:18:42 +00:00
Update ci.yml
This commit is contained in:
1 parent
dfe7a94acd
commit
e5d1d64c4b
1 file changed
+13
-5
@@ -24,6 +24,9 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
- run: npm install
|
- run: npm install
|
||||||
|
|
||||||
@@ -39,11 +42,16 @@ jobs:
|
|||||||
|
|
||||||
- name: Get changed files
|
- name: Get changed files
|
||||||
if: github.event_name == 'pull_request'
|
if: github.event_name == 'pull_request'
|
||||||
run: |
|
uses: actions/github-script@v6
|
||||||
CHANGED_FILES=$(gh pr view ${{ github.event.pull_request.number }} --json files -q '.files[].path' | jq -c .)
|
with:
|
||||||
echo "CHANGED_FILES=$CHANGED_FILES" >> $GITHUB_ENV
|
script: |
|
||||||
env:
|
const { execSync } = require("child_process")
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
const { commits } = context.payload.pull_request
|
||||||
|
const rawFiles = execSync(`git diff --name-only HEAD HEAD~${commits}`).toString()
|
||||||
|
const files = rawFiles.split("\n").filter(Boolean)
|
||||||
|
console.log(files)
|
||||||
|
const jsonArray = JSON.stringify(files)
|
||||||
|
core.exportVariable('CHANGED_FILES', jsonArray)
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: npx ava tests/*.test.js
|
run: npx ava tests/*.test.js
|
||||||
Reference in new issue
Block a user