Skip to content

Merge pull request #1765 from grafana/aws/v0.13.0 #1873

Merge pull request #1765 from grafana/aws/v0.13.0

Merge pull request #1765 from grafana/aws/v0.13.0 #1873

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@v4
- name: Use Node.js 20.xs
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
- name: Restore node_modules cache
uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}
- name: Install
run: npm install
- name: Restore Gatsby cache
uses: actions/cache@v4
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
build-deploy-staging:
name: Build and deploy to staging
runs-on: ubuntu-latest
needs:
- lint
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Use Node.js 20.xs
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
- name: Restore node_modules cache
uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}
- name: Install
run: npm install
- name: Restore Gatsby cache
uses: actions/cache@v4
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