15
15
branches : main
16
16
17
17
jobs :
18
- update-dependencies :
19
- name : Update node module dependencies
20
- runs-on : ubuntu-latest
21
- steps :
22
- - name : Checkout project
23
- uses : actions/checkout@v2
24
- - name : Use Node.js 16.xs
25
- uses : actions/setup-node@v2
26
- with :
27
- node-version : ' 16.x'
28
- registry-url : ' https://registry.npmjs.org'
29
- cache : ' npm'
30
- - name : Restore cache
31
- uses : actions/cache@v2
32
- with :
33
- path : ' **/node_modules'
34
- key : ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}
35
- - name : Install dependencies
36
- run : npm install
37
18
lint :
38
19
name : Lint code
39
- needs : [update-dependencies]
40
20
runs-on : ubuntu-latest
41
21
steps :
42
22
- name : Checkout project
77
57
fail_on_error : true
78
58
vale_flags : ' --glob=**/{docs,translated-guides/en}/**/*.md'
79
59
build :
80
- name : Build pull request
60
+ name : Build and deploy pull request
81
61
runs-on : ubuntu-latest
82
62
needs : lint
83
63
steps :
98
78
registry-url : ' https://registry.npmjs.org'
99
79
cache : ' npm'
100
80
81
+ - name : Restore node_modules cache
82
+ uses : actions/cache@v2
83
+ with :
84
+ path : ' **/node_modules'
85
+ key : ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}
86
+
101
87
- name : Install
102
88
run : npm install
103
89
@@ -117,47 +103,35 @@ jobs:
117
103
- name : Build
118
104
run : npm run build
119
105
120
- - name : Upload artifact
121
- uses : actions/upload-artifact@v2
122
- with :
123
- name : k6-docs
124
- path : public/
125
- retention-days : 1
126
-
127
- deploy :
128
- name : Deploy pull request
129
- runs-on : ubuntu-latest
130
- needs : [build]
131
- if : github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]'
132
- env :
133
- AWS_ACCESS_KEY_ID : ${{ secrets.PR_CI_AWS_ACCESS_KEY }}
134
- AWS_SECRET_ACCESS_KEY : ${{ secrets.PR_CI_AWS_SECRET_KEY }}
135
- AWS_REGION : ' eu-west-1'
136
-
137
- steps :
138
- - name : Download artifact
139
- uses : actions/download-artifact@v2
140
- with :
141
- name : k6-docs
142
- path : public/
143
-
144
106
- name : Sync to S3
107
+ id : upload
108
+ # Run only if PR does not come from a fork and it is not from dependabot.
109
+ if : github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]'
145
110
uses :
jakejarvis/[email protected]
146
111
with :
147
112
args : --delete
148
113
env :
114
+ AWS_ACCESS_KEY_ID : ${{ secrets.PR_CI_AWS_ACCESS_KEY }}
115
+ AWS_SECRET_ACCESS_KEY : ${{ secrets.PR_CI_AWS_SECRET_KEY }}
116
+ AWS_REGION : ' eu-west-1'
149
117
AWS_S3_BUCKET : ${{ secrets.PR_CI_AWS_S3_BUCKET }}
150
118
SOURCE_DIR : public/
151
119
DEST_DIR : docs/${{ github.ref }}
152
120
153
121
- name : Invalidate Cloudfront
122
+ # Run only if we did not skip the upload step
123
+ if : steps.upload.outcome == 'success'
154
124
155
125
env :
126
+ AWS_ACCESS_KEY_ID : ${{ secrets.PR_CI_AWS_ACCESS_KEY }}
127
+ AWS_SECRET_ACCESS_KEY : ${{ secrets.PR_CI_AWS_SECRET_KEY }}
128
+ AWS_REGION : ' eu-west-1'
156
129
DISTRIBUTION : ${{ secrets.PR_CI_CLOUDFRONT_DISTRIBUTION_ID }}
157
130
PATHS : ' /docs/*'
158
131
159
132
- name : Post published URL to PR
160
- if : github.event.action == 'opened'
133
+ # Run only if we did not skip the upload step and it's the first run for this PR.
134
+ if : steps.upload.outcome == 'success' && github.event.action == 'opened'
161
135
162
136
with :
163
137
github-token : ${{secrets.GITHUB_TOKEN}}
0 commit comments