diff --git a/.github/workflows/pr-deploy.yml b/.github/workflows/pr-deploy.yml new file mode 100644 index 000000000..30f97a653 --- /dev/null +++ b/.github/workflows/pr-deploy.yml @@ -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/s3-sync-action@v0.5.1 + 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/invalidate-cloudfront-action@v1.2 + env: + DISTRIBUTION: ${{ secrets.PR_CI_CLOUDFRONT_DISTRIBUTION_ID }} + PATHS: '/docs/*' + + - name: Post published URL to PR + if: github.event.action == 'opened' + uses: actions/github-script@0.8.0 + 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.', + }) diff --git a/gatsby-config.js b/gatsby-config.js index 0b4eef828..25ef1db1b 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -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; @@ -276,7 +276,7 @@ if (process.env.BUCKET_NAME) { } module.exports = { - pathPrefix: `/docs`, + pathPrefix: process.env.PATH_PREFIX || `/docs`, siteMetadata: { siteTitle: diff --git a/src/styles/parts/fonts.scss b/src/styles/parts/fonts.scss index 6ec28ec50..4731377f2 100644 --- a/src/styles/parts/fonts.scss +++ b/src/styles/parts/fonts.scss @@ -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'); }