Dev #19
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 Workflow | |
on: | |
pull_request: | |
branches: | |
- main | |
- dev | |
types: | |
- opened | |
- synchronize | |
jobs: | |
Run_tests: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout branch | |
uses: actions/checkout@v4 | |
- name: Setup action | |
uses: pnpm/action-setup@v4 | |
with: | |
version: latest | |
- name: Setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: "pnpm" | |
- name: Install Dependencies | |
run: pnpm install | |
- name: Run tests | |
run: | | |
pnpm test 2>&1 | tee test.log | |
exit ${PIPESTATUS[0]} | |
- name: Comment on PR if lint fails | |
if: failure() | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.TOKEN_FOR_CI }} | |
script: | | |
const fs = require('fs'); | |
const log = fs.readFileSync('test.log', 'utf8'); | |
github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
body: `### ❌ Test Failed\n\`\`\`\n${log}\n\`\`\`` | |
}); | |
Run_linter: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout branch | |
uses: actions/checkout@v4 | |
- name: Setup action | |
uses: pnpm/action-setup@v4 | |
with: | |
version: latest | |
- name: Setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: "pnpm" | |
- name: Install Dependencies | |
run: pnpm install | |
- name: Run linter | |
run: | | |
pnpm lint 2>&1 | tee lint.log | |
exit ${PIPESTATUS[0]} | |
- name: Comment on PR if lint fails | |
if: failure() | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.TOKEN_FOR_CI }} | |
script: | | |
const fs = require('fs'); | |
const log = fs.readFileSync('lint.log', 'utf8'); | |
github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
body: `### ❌ Lint Failed\n\`\`\`\n${log}\n\`\`\`` | |
}); | |
Build_project: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout branch | |
uses: actions/checkout@v4 | |
- name: Setup action | |
uses: pnpm/action-setup@v4 | |
with: | |
version: latest | |
- name: Setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: "pnpm" | |
- name: Install Dependencies | |
run: pnpm install | |
- name: Build project | |
run: pnpm build | |
- name: Comment on PR if build fails | |
if: failure() | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.TOKEN_FOR_CI }} | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: "### ❌ Build Failed" | |
}) |