Skip to content

Commit

Permalink
Merge pull request #114 from loadimpact/chore/build-and-deploy-pr
Browse files Browse the repository at this point in the history
[chore] deploy a version of docs when PR is created
  • Loading branch information
allansson authored Oct 30, 2020
2 parents be1bce1 + b2772c0 commit 9019ada
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 8 deletions.
92 changes: 92 additions & 0 deletions .github/workflows/pr-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Pull Request CI

env:
PATH_PREFIX: /docs/${{ github.ref }}
GATSBY_DEFAULT_MAIN_URL: https://staging.k6.io
GATSBY_DEFAULT_DOC_URL: https://mdr-ci.staging.k6.io/docs/${{ github.ref }}
GATSBY_DEFAULT_BLOG_URL: https://k6.io/blog
GATSBY_DEFAULT_APP_URL: https://app.staging.k6.io

on:
pull_request:
branches: master

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Print build settings
run: |
echo "PATH_PREFIX: $PATH_PREFIX"
echo "GATSBY_DEFAULT_MAIN_URL: $GATSBY_DEFAULT_MAIN_URL"
echo "GATSBY_DEFAULT_DOC_URL: $GATSBY_DEFAULT_DOC_URL"
echo "GATSBY_DEFAULT_BLOG_URL: $GATSBY_DEFAULT_BLOG_URL"
echo "GATSBY_DEFAULT_APP_URL: $GATSBY_DEFAULT_APP_URL"
- name: Use Node.js 12.xs
uses: actions/setup-node@v1
with:
node-version: '12.x'
registry-url: 'https://registry.npmjs.org'

- name: Install
run: npm install

- name: Build
run: npm run build

- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: k6-docs
path: public/

deploy:
runs-on: ubuntu-latest
needs: [build]

env:
AWS_ACCESS_KEY_ID: ${{ secrets.PR_CI_AWS_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.PR_CI_AWS_SECRET_KEY }}
AWS_REGION: 'eu-west-1'

steps:
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: k6-docs
path: public/

- name: Sync to S3
uses: jakejarvis/[email protected]
with:
args: --delete
env:
AWS_S3_BUCKET: ${{ secrets.PR_CI_AWS_S3_BUCKET }}
SOURCE_DIR: public/
DEST_DIR: docs/${{ github.ref }}

- name: Invalidate Cloudfront
uses: chetan/[email protected]
env:
DISTRIBUTION: ${{ secrets.PR_CI_CLOUDFRONT_DISTRIBUTION_ID }}
PATHS: '/docs/*'

- name: Post published URL to PR
if: github.event.action == 'opened'
uses: actions/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.createComment({
issue_number: context.payload.number,
owner: context.repo.owner,
repo: context.repo.repo,
body:
"There's a version of the docs published here:\n\n" +
`${process.env.GATSBY_DEFAULT_DOC_URL}\n\n` +
'It will be deleted automatically in 30 days.',
})
4 changes: 2 additions & 2 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require('dotenv').config({

const mainURL = process.env.GATSBY_DEFAULT_DOC_URL;
const isProduction = mainURL === 'https://k6.io/docs';
const isStaging = mainURL === 'https://staging.k6.io/docs';
const isStaging = mainURL.startsWith('https://staging.k6.io');

const shouldAnnouncementBannerBeShown = false;

Expand Down Expand Up @@ -276,7 +276,7 @@ if (process.env.BUCKET_NAME) {
}

module.exports = {
pathPrefix: `/docs`,
pathPrefix: process.env.PATH_PREFIX || `/docs`,

siteMetadata: {
siteTitle:
Expand Down
18 changes: 12 additions & 6 deletions src/styles/parts/fonts.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,28 @@
font-family: 'TT Norms Pro';
font-style: normal;
font-weight: 400;
src: url('/fonts/tt-norms-pro/tt-pro-regular-webfont.woff2') format('woff2'),
url('/fonts/tt-norms-pro/tt-pro-regular-webfont.woff') format('woff');
src: url('../../static/fonts/tt-norms-pro/tt-pro-regular-webfont.woff2')
format('woff2'),
url('../../static/fonts/tt-norms-pro/tt-pro-regular-webfont.woff')
format('woff');
}

@font-face {
font-family: 'TT Norms Pro';
font-style: normal;
font-weight: 500;
src: url('/fonts/tt-norms-pro/tt-pro-medium-webfont.woff2') format('woff2'),
url('/fonts/tt-norms-pro/tt-pro-medium-webfont.woff') format('woff');
src: url('../../static/fonts/tt-norms-pro/tt-pro-medium-webfont.woff2')
format('woff2'),
url('../../static/fonts/tt-norms-pro/tt-pro-medium-webfont.woff')
format('woff');
}

@font-face {
font-family: 'TT Norms Pro';
font-style: normal;
font-weight: 700;
src: url('/fonts/tt-norms-pro/tt-pro-bold-webfont.woff2') format('woff2'),
url('/fonts/tt-norms-pro/tt-pro-bold-webfont.woff') format('woff');
src: url('../../static/fonts/tt-norms-pro/tt-pro-bold-webfont.woff2')
format('woff2'),
url('../../static/fonts/tt-norms-pro/tt-pro-bold-webfont.woff')
format('woff');
}

0 comments on commit 9019ada

Please sign in to comment.