Skip to content

chore: fix PR deploy action to post a comment (#1235) #1434

chore: fix PR deploy action to post a comment (#1235)

chore: fix PR deploy action to post a comment (#1235) #1434

Workflow file for this run

name: Staging
on:
push:
branches:
- main
env:
ALGOLIA_ADMIN_KEY: ${{ secrets.STAGING_CI_ALGOLIA_ADMIN_KEY }}
AWS_ACCESS_KEY_ID: ${{ secrets.STAGING_CI_AWS_ACCESS_KEY }}
AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.STAGING_CI_AWS_CLOUDFRONT_DISTRIBUTION_ID }}
AWS_REGION: 'eu-west-1'
AWS_SECRET_ACCESS_KEY: ${{ secrets.STAGING_CI_AWS_SECRET_KEY }}
BUCKET_NAME: ${{ secrets.STAGING_CI_BUCKET_NAME }}
BUCKET_REGION: ${{ secrets.STAGING_CI_BUCKET_REGION }}
GATSBY_ALGOLIA_APP_ID: ${{ secrets.STAGING_CI_GATSBY_ALGOLIA_APP_ID }}
GATSBY_ALGOLIA_INDEX_NAME: ${{ secrets.STAGING_CI_GATSBY_ALGOLIA_INDEX_NAME }}
GATSBY_ALGOLIA_SEARCH_ONLY_KEY: ${{ secrets.STAGING_CI_GATSBY_ALGOLIA_SEARCH_ONLY_KEY }}
GATSBY_DEFAULT_APP_URL: https://app.staging.k6.io
GATSBY_DEFAULT_BLOG_URL: https://staging.k6.io/blog
GATSBY_DEFAULT_DOC_URL: https://staging.k6.io/docs
GATSBY_DEFAULT_MAIN_URL: https://staging.k6.io
GATSBY_GOOGLE_API_KEY: ${{ secrets.STAGING_CI_GATSBY_GOOGLE_API_KEY }}
GATSBY_NEWSLETTER_FORM_URL: https://go2.grafana.com
GATSBY_NEWSLETTER_FORM_MUNCHKIN_ID: 356-YFG-389
GATSBY_NEWSLETTER_FORM_ID: 1420
jobs:
lint:
name: Lint code
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v3
- name: Use Node.js 16.xs
uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
- name: Restore node_modules cache
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}
- name: Install
run: npm install
- name: Restore Gatsby cache
uses: actions/cache@v3
with:
# Gatsby requires both .cache and public. It will refuse to use .cache/ if public/ is not present.
path: |
.cache
public
# Cache will not be used by Gatsby if the following files change:
# https://www.gatsbyjs.com/docs/build-caching/
# We use the commit SHA on the key to prevent an ever-living cache entry keyed as "main".
key: pr-gatsby-${{ hashFiles('package.json', 'gatsby-config.js', 'gatsby-node.js') }}-${{ github.ref }}-${{ github.sha }}
restore-keys: |
pr-gatsby-${{ hashFiles('package.json', 'gatsby-config.js', 'gatsby-node.js') }}-${{ github.ref }}-
pr-gatsby-${{ hashFiles('package.json', 'gatsby-config.js', 'gatsby-node.js') }}-
- name: Check formatting
run: |
npm run format
- name: Lint code
run: |
npm run lint
- name: Lint code examples
run: |
npm run lint:examples
lint-prose:
name: Lint prose
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: errata-ai/vale-action@reviewdog
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
files: ./src/data/markdown
version: 2.17.0
fail_on_error: true
vale_flags: '--glob=**/{docs,translated-guides/en}/**/*.md'
build-deploy-staging:
name: Build and deploy to staging
runs-on: ubuntu-latest
needs:
- lint
steps:
- name: Checkout project
uses: actions/checkout@v3
- name: Use Node.js 16.xs
uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
- name: Restore node_modules cache
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}
- name: Install
run: npm install
- name: Restore Gatsby cache
uses: actions/cache@v3
with:
# Gatsby requires both .cache and public. It will refuse to use .cache/ if public/ is not present.
path: |
.cache
public
# Cache will not be used by Gatsby if the following files change:
# https://www.gatsbyjs.com/docs/build-caching/
key: pr-gatsby-${{ hashFiles('package.json', 'gatsby-config.js', 'gatsby-node.js') }}-${{ github.ref }}
restore-keys: |
pr-gatsby-${{ hashFiles('package.json', 'gatsby-config.js', 'gatsby-node.js') }}-
- name: Build project
run: npm run build:gatsby
- name: Checks if AWS CLI already installed
run: (command -v aws >/dev/null && echo "is_aws_installed=true" || echo "is_aws_installed=false") >> $GITHUB_ENV
- name: Download AWS CLI
if: ${{ !env.is_aws_installed }}
run: curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && unzip awscliv2.zip
- name: Install AWS CLI
if: ${{ !env.is_aws_installed }}
run: sudo ./aws/install
- name: Confirm the installation
run: aws --version
- name: Deploy
run: npm run deploy
linkinator:
name: "Checks broken links"
runs-on: ubuntu-latest
needs: [build-deploy-staging]
continue-on-error: true
steps:
- uses: actions/checkout@v3
- uses: JustinBeckwith/linkinator-action@v1
with:
paths: ${{ env.GATSBY_DEFAULT_DOC_URL }}
concurrency: 50
recurse: true
retry: true
skip: ".*(\\.js|\\.css)$"
linksToSkip: >-
localhost,
https://linkedin.com,
googleapis.com,
https://www.linkedin.com/company/k6io,
https://staging.k6.io/slack,
https://twitter.com/k6_io
verbosity: "ERROR"
markdown: false