-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (113 loc) · 3.51 KB
/
on-pull-request.yml
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: On pull request
on:
pull_request:
branches:
- main
permissions: write-all
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version:
- 20.x
steps:
- name: Checkouting code...
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: NPM install
run: npm install
- name: NPM test
run: npm run test
build:
runs-on: ubuntu-latest
needs: test
strategy:
matrix:
node-version:
- 20.x
steps:
- name: Checkouting code...
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: NPM install
run: npm install
- name: NPM build
run: npm run build
- name: NPM format
run: npm run format
- name: NPM format check
run: npm run format-check
- name: Lint
run: npm run lint
- name: Pack
run: npm run pack
- name: Uploading build artifact...
uses: actions/upload-artifact@v4
with:
name: build
path: dist/*.js
commit_and_push:
runs-on: ubuntu-latest
name: Commit and push build if needed
needs: build
steps:
- name: Checkouting code...
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Downloading build artifact....
uses: actions/download-artifact@v4
with:
name: build
path: dist/
- name: Auto commiting changes...
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Automatically builded and updated
file_pattern: dist/*.js
skip_fetch: true
skip_checkout: true
dependabot:
needs:
- build
- commit_and_push
permissions:
pull-requests: write
contents: write
runs-on: ubuntu-latest
# Checking the actor will prevent your Action run failing on non-Dependabot
# PRs but also ensures that it only does work for Dependabot PRs.
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
# This first step will fail if there's no metadata and so the approval
# will not occur.
- name: Dependabot metadata
id: dependabot-metadata
uses: dependabot/fetch-metadata@v1.6.0
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
# Here the PR gets approved.
- name: Approve a PR
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Finally, this sets the PR to allow auto-merging for patch and minor
# updates if all checks pass
- name: Enable auto-merge for Dependabot PRs
# if: ${{ steps.dependabot-metadata.outputs.update-type != 'version-update:semver-major' }}
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}