-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (104 loc) · 3.54 KB
/
build.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
on:
issue_comment:
types: [ created ]
jobs:
lint_and_build:
name: Run CI.
if: ${{ github.event.issue.pull_request && github.event.comment.body == '/lint-and-build' }}
permissions:
issues: write
pull-requests: write
contents: write
runs-on: ubuntu-latest
steps:
- name: Reaction emoji
uses: actions-cool/issues-helper@v3
with:
actions: 'update-comment'
token: ${{ secrets.GITHUB_TOKEN }}
comment-id: ${{ github.event.comment.id }}
emoji: '+1'
- name: Get pull request branch
id: pr_branch
uses: actions/github-script@v7
with:
script: |
const pr_number = "${{ github.event.issue.number }}";
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr_number,
});
core.debug(`pull_number is ${pr_number}`)
core.debug(pr.data)
return pr.data.head.ref;
result-encoding: string
- name: Checkout Main Repository
uses: actions/checkout@v4
with:
ref: ${{ steps.pr_branch.outputs.result }}
path: repo
- uses: pnpm/action-setup@v2
with:
version: 9.12.x
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: "20"
cache: 'pnpm'
cache-dependency-path: repo/pnpm-lock.yaml
- name: Install dependencies
run: cd repo && pnpm i
- name: Lint Project
run: cd repo && pnpm run lint
- name: Build Project
run: cd repo && pnpm run build
- name: Push Project
run: >
cd repo &&
git config --global user.name "github-actions[bot]" &&
git config --global user.email "github-actions[bot]@users.noreply.github.com" &&
git add . &&
git commit -m "chore: lint and build project" &&
git commit -m "chore: lint project" &&
git push origin $BRANCH
echo "passed=1" >> "$GITHUB_OUTPUT"
- name: Remove Failed Label
uses: actions-cool/issues-helper@v3
with:
actions: 'remove-labels'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
labels: 'build:failed'
- name: Create Build Success Label
uses: actions-cool/issues-helper@v3
with:
actions: 'add-labels'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
labels: 'build:success'
tip_ci_failed:
needs: lint_and_build
if: ${{ failure() }}
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: Create label
uses: actions-cool/issues-helper@v3
with:
actions: 'add-labels'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
labels: 'build:failed'
- name: Add failed comment
if: needs.lint_and_build.outputs.lint_passed != 1
uses: actions-cool/issues-helper@v3
with:
actions: 'create-comment'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
body: |
@${{ github.event.issue.user.login }}.
Failed to lint or build project. [Click here](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) to check the workflow.