-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #114 from loadimpact/chore/build-and-deploy-pr
[chore] deploy a version of docs when PR is created
- Loading branch information
Showing
3 changed files
with
106 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.', | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters