mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-05-14 10:58:46 +00:00
58 lines
1.8 KiB
YAML
58 lines
1.8 KiB
YAML
name: CI
|
|
|
|
on:
|
|
pull_request:
|
|
|
|
push:
|
|
branches: [main]
|
|
paths:
|
|
- "domains/*"
|
|
- "tests/*"
|
|
- "util/*"
|
|
- ".github/workflows/ci.yml"
|
|
- "dnsconfig.js"
|
|
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: ${{ github.ref }}-ci
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
tests:
|
|
name: Tests
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
fetch-depth: 0
|
|
|
|
- run: npm install
|
|
|
|
- name: Get PR author
|
|
if: github.event_name == 'pull_request'
|
|
run: echo "PR_AUTHOR=${{ github.event.pull_request.user.login }}" >> $GITHUB_ENV
|
|
|
|
- name: Get PR labels
|
|
if: github.event_name == 'pull_request'
|
|
run: |
|
|
LABELS=$(jq -c '[.pull_request.labels[].name]' <<< '${{ toJson(github.event) }}')
|
|
echo "PR_LABELS=$LABELS" >> $GITHUB_ENV
|
|
|
|
- name: Get changed files
|
|
if: github.event_name == 'pull_request'
|
|
uses: actions/github-script@v6
|
|
with:
|
|
script: |
|
|
const { execSync } = require("child_process")
|
|
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
|
|
run: npx ava tests/*.test.js
|