Skip to content

Commit 9019ada

Browse files
authored
Merge pull request #114 from loadimpact/chore/build-and-deploy-pr
[chore] deploy a version of docs when PR is created
2 parents be1bce1 + b2772c0 commit 9019ada

File tree

3 files changed

+106
-8
lines changed

3 files changed

+106
-8
lines changed

.github/workflows/pr-deploy.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Pull Request CI
2+
3+
env:
4+
PATH_PREFIX: /docs/${{ github.ref }}
5+
GATSBY_DEFAULT_MAIN_URL: https://staging.k6.io
6+
GATSBY_DEFAULT_DOC_URL: https://mdr-ci.staging.k6.io/docs/${{ github.ref }}
7+
GATSBY_DEFAULT_BLOG_URL: https://k6.io/blog
8+
GATSBY_DEFAULT_APP_URL: https://app.staging.k6.io
9+
10+
on:
11+
pull_request:
12+
branches: master
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v2
20+
21+
- name: Print build settings
22+
run: |
23+
echo "PATH_PREFIX: $PATH_PREFIX"
24+
echo "GATSBY_DEFAULT_MAIN_URL: $GATSBY_DEFAULT_MAIN_URL"
25+
echo "GATSBY_DEFAULT_DOC_URL: $GATSBY_DEFAULT_DOC_URL"
26+
echo "GATSBY_DEFAULT_BLOG_URL: $GATSBY_DEFAULT_BLOG_URL"
27+
echo "GATSBY_DEFAULT_APP_URL: $GATSBY_DEFAULT_APP_URL"
28+
29+
- name: Use Node.js 12.xs
30+
uses: actions/setup-node@v1
31+
with:
32+
node-version: '12.x'
33+
registry-url: 'https://registry.npmjs.org'
34+
35+
- name: Install
36+
run: npm install
37+
38+
- name: Build
39+
run: npm run build
40+
41+
- name: Upload artifact
42+
uses: actions/upload-artifact@v2
43+
with:
44+
name: k6-docs
45+
path: public/
46+
47+
deploy:
48+
runs-on: ubuntu-latest
49+
needs: [build]
50+
51+
env:
52+
AWS_ACCESS_KEY_ID: ${{ secrets.PR_CI_AWS_ACCESS_KEY }}
53+
AWS_SECRET_ACCESS_KEY: ${{ secrets.PR_CI_AWS_SECRET_KEY }}
54+
AWS_REGION: 'eu-west-1'
55+
56+
steps:
57+
- name: Download artifact
58+
uses: actions/download-artifact@v2
59+
with:
60+
name: k6-docs
61+
path: public/
62+
63+
- name: Sync to S3
64+
uses: jakejarvis/[email protected]
65+
with:
66+
args: --delete
67+
env:
68+
AWS_S3_BUCKET: ${{ secrets.PR_CI_AWS_S3_BUCKET }}
69+
SOURCE_DIR: public/
70+
DEST_DIR: docs/${{ github.ref }}
71+
72+
- name: Invalidate Cloudfront
73+
uses: chetan/[email protected]
74+
env:
75+
DISTRIBUTION: ${{ secrets.PR_CI_CLOUDFRONT_DISTRIBUTION_ID }}
76+
PATHS: '/docs/*'
77+
78+
- name: Post published URL to PR
79+
if: github.event.action == 'opened'
80+
uses: actions/[email protected]
81+
with:
82+
github-token: ${{secrets.GITHUB_TOKEN}}
83+
script: |
84+
github.issues.createComment({
85+
issue_number: context.payload.number,
86+
owner: context.repo.owner,
87+
repo: context.repo.repo,
88+
body:
89+
"There's a version of the docs published here:\n\n" +
90+
`${process.env.GATSBY_DEFAULT_DOC_URL}\n\n` +
91+
'It will be deleted automatically in 30 days.',
92+
})

gatsby-config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require('dotenv').config({
77

88
const mainURL = process.env.GATSBY_DEFAULT_DOC_URL;
99
const isProduction = mainURL === 'https://k6.io/docs';
10-
const isStaging = mainURL === 'https://staging.k6.io/docs';
10+
const isStaging = mainURL.startsWith('https://staging.k6.io');
1111

1212
const shouldAnnouncementBannerBeShown = false;
1313

@@ -276,7 +276,7 @@ if (process.env.BUCKET_NAME) {
276276
}
277277

278278
module.exports = {
279-
pathPrefix: `/docs`,
279+
pathPrefix: process.env.PATH_PREFIX || `/docs`,
280280

281281
siteMetadata: {
282282
siteTitle:

src/styles/parts/fonts.scss

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,28 @@
2929
font-family: 'TT Norms Pro';
3030
font-style: normal;
3131
font-weight: 400;
32-
src: url('/fonts/tt-norms-pro/tt-pro-regular-webfont.woff2') format('woff2'),
33-
url('/fonts/tt-norms-pro/tt-pro-regular-webfont.woff') format('woff');
32+
src: url('../../static/fonts/tt-norms-pro/tt-pro-regular-webfont.woff2')
33+
format('woff2'),
34+
url('../../static/fonts/tt-norms-pro/tt-pro-regular-webfont.woff')
35+
format('woff');
3436
}
3537

3638
@font-face {
3739
font-family: 'TT Norms Pro';
3840
font-style: normal;
3941
font-weight: 500;
40-
src: url('/fonts/tt-norms-pro/tt-pro-medium-webfont.woff2') format('woff2'),
41-
url('/fonts/tt-norms-pro/tt-pro-medium-webfont.woff') format('woff');
42+
src: url('../../static/fonts/tt-norms-pro/tt-pro-medium-webfont.woff2')
43+
format('woff2'),
44+
url('../../static/fonts/tt-norms-pro/tt-pro-medium-webfont.woff')
45+
format('woff');
4246
}
4347

4448
@font-face {
4549
font-family: 'TT Norms Pro';
4650
font-style: normal;
4751
font-weight: 700;
48-
src: url('/fonts/tt-norms-pro/tt-pro-bold-webfont.woff2') format('woff2'),
49-
url('/fonts/tt-norms-pro/tt-pro-bold-webfont.woff') format('woff');
52+
src: url('../../static/fonts/tt-norms-pro/tt-pro-bold-webfont.woff2')
53+
format('woff2'),
54+
url('../../static/fonts/tt-norms-pro/tt-pro-bold-webfont.woff')
55+
format('woff');
5056
}

0 commit comments

Comments
 (0)