ci: fixes to support outside contributors (#26) #55
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
pull_request_target: | |
types: [opened, synchronize] | |
push: | |
branches: | |
- "main" | |
jobs: | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v3 | |
with: | |
cache: "npm" | |
node-version-file: ".nvmrc" | |
- uses: nrwl/nx-set-shas@v3 | |
- run: npm i | |
- run: npx nx --version | |
- run: npx nx run-many --targets=lint | |
- run: npx prettier --check . | |
build-and-test: | |
name: Build and test | |
runs-on: ubuntu-latest | |
permissions: | |
contents: "read" | |
actions: "read" | |
pull-requests: write | |
steps: | |
- name: Get User Permission | |
id: checkAccess | |
uses: actions-cool/check-user-permission@v2 | |
with: | |
require: write | |
username: ${{ github.triggering_actor }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Check User Permission | |
if: steps.checkAccess.outputs.require-result == 'false' | |
run: | | |
echo "${{ github.triggering_actor }} does not have permissions on this repo." | |
echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}" | |
echo "Job originally triggered by ${{ github.actor }}" | |
exit 1 | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v3 | |
with: | |
cache: "npm" | |
node-version-file: ".nvmrc" | |
- uses: nrwl/nx-set-shas@v3 | |
- run: npm i | |
- name: Build | |
run: npx nx affected --target=build --parallel=3 | |
- name: Test | |
run: npx nx affected --target=test --parallel=3 --ci --code-coverage |