-
Notifications
You must be signed in to change notification settings - Fork 222
152 lines (149 loc) · 5.58 KB
/
staging.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
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]
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