-
Notifications
You must be signed in to change notification settings - Fork 324
61 lines (54 loc) · 2.21 KB
/
main.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
name: Check format
run-name: Checking format
on:
pull_request:
branches:
- master
jobs:
install:
name: "Install"
runs-on: ubuntu-latest
steps:
- name: Checkout files
uses: actions/checkout@v3
- name: Install node_modules
# This action does not work very well with subdirectories out of the box,
# but we can use this workaround to make it work.
# Note that this is highly dependent on the version of the action used
uses: OffchainLabs/actions/node-modules/install@35a1f8c3f3ad803e1fd9b81b94d063a4fc90a030
with:
install-command: cd website && yarn install --frozen-lockfile
cache-key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
check-formatting:
name: "Check Formatting - does not fail, only comments on error"
runs-on: ubuntu-latest
needs: install
steps:
- name: Checkout files
uses: actions/checkout@v3
- name: Restore node_modules
# This action does not work very well with subdirectories out of the box,
# but we can use this workaround to make it work.
# Note that this is highly dependent on the version of the action used
uses: OffchainLabs/actions/node-modules/restore@35a1f8c3f3ad803e1fd9b81b94d063a4fc90a030
with:
cache-key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- name: Check formatting with Prettier
id: prettier-check
working-directory: ./website
run: |
set +e
yarn format:check
echo "format-check-result=$?" >> $GITHUB_OUTPUT
- name: Output formatting error
if: steps.prettier-check.outputs.format-check-result == 1
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: 'Hey there!\nIt looks like your changes are not well formatted. You can merge this PR, but we recommend to format your code with:\n```\ncd website && yarn format\n```\nThanks!💙🧡'
})