-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (129 loc) · 4.14 KB
/
build.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
name: build
on:
push:
branches: [ master ]
pull_request_target:
branches: [ master ]
jobs:
wait:
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- name: 'wait for previous workflows to finish'
uses: softprops/turnstyle@v1
with:
same-branch-only: false
poll-interval-seconds: 10
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [10.x, 12.x, 13.x, 14.x]
os: [ubuntu-latest]
defaults:
run:
shell: bash
name: node.js ${{ matrix.node-version }}
steps:
- uses: actions/[email protected]
with:
ref: ${{ github.head_ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: setup node.js ${{ matrix.node-version }}
uses: actions/[email protected]
with:
node-version: ${{ matrix.node-version }}
- name: caching node modules
uses: actions/[email protected]
with:
path: node_modules
key: ${{ runner.OS }}-build-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.OS }}-build-${{ matrix.node-version }}
${{ runner.OS }}-build
- name: installing dependencies
if: steps.cache-primes.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile
env:
CI: true
- name: running tests
run: yarn test
env:
CI: true
test-cli:
needs: [wait, build]
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- uses: actions/[email protected]
with:
ref: ${{ github.head_ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- uses: bahmutov/[email protected]
- name: create test file
run: echo "This is a test for ${{ github.sha }} by ${{ github.run_id }}" > test.md
- name: run cli test
run: node ./cli.js --file "test.md" --page "test-cli" --site ${{ secrets.SITELEAF_TEST_SITE }}
env:
SITELEAF_API_KEY: ${{ secrets.SITELEAF_TEST_KEY }}
SITELEAF_API_SECRET: ${{ secrets.SITELEAF_TEST_SECRET }}
test-action:
needs: [wait, build]
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- uses: actions/[email protected]
with:
ref: ${{ github.head_ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: create test file
run: echo "This is a test for ${{ github.sha }} by ${{ github.run_id }}" > test.md
- name: run action test
id: siteleaf
uses: ./
with:
api-key: ${{ secrets.SITELEAF_TEST_KEY }}
api-secret: ${{ secrets.SITELEAF_TEST_SECRET }}
site: ${{ secrets.SITELEAF_TEST_SITE }}
page: 'test-action'
file: 'test.md'
verify:
needs: [test-cli, test-action]
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- uses: actions/[email protected]
with:
repository: 'gofunky/siteleaf-test'
ref: 'master'
token: ${{ secrets.PAT }}
- name: only use fast-forward pulls
run: git config pull.ff only
- name: verify test runs
uses: nick-invision/retry@v2
with:
retry_wait_seconds: 10
timeout_minutes: 1
max_attempts: 3
command: |
git pull origin siteleaf-test
if grep -Fq "${{ github.sha }} by ${{ github.run_id }}" "test-action.markdown"; then
echo "the action-based markdown push is verified"
else
echo "::warning file=test-action.markdown::the action-based markdown push can not be verified yet"
exit 1
fi
if grep -Fq "${{ github.sha }} by ${{ github.run_id }}" "test-cli.markdown"; then
echo "the cli-based markdown push is verified"
else
echo "::warning file=test-cli.markdown::the cli-based markdown push can not be verified yet"
exit 1
fi