-
Notifications
You must be signed in to change notification settings - Fork 17
139 lines (126 loc) · 4.73 KB
/
main.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
name: Publish website
on:
push:
branches:
- gatsby
- staging
workflow_dispatch:
inputs:
partytownEnabled:
description: 'Enable partytown'
required: true
default: 'false'
type: choice
options:
- 'true'
- 'false'
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- name: Yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v3
name: Yarn cache
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-v29-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-v29-
- name: Restore Gatsby Cache
id: gatsby-cache-restore
uses: actions/cache/restore@v3
with:
path: |
public
.cache
key: ${{ runner.os }}-gatsby-build-v29-${{ github.ref_name }}
- run: yarn install
- run: yarn tsc --noEmit
- run: yarn run build
if: ${{ github.ref == 'refs/heads/gatsby' }}
env:
CI: true
GATSBY_ACTIVE_ENV: production
GATSBY_CPU_COUNT: 1
GATSBY_PARTYTOWN_ENABLED: ${{ inputs.partytownEnabled || 'false' }}
- run: yarn run deploy-s3
if: ${{ github.ref == 'refs/heads/gatsby' }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.PRODUCTION_CLOUDFRONT_DISTRIBUTION_ID }}
GATSBY_ACTIVE_ENV: production
- run: yarn run invalidate-cf-cache
if: ${{ github.ref == 'refs/heads/gatsby' }}
env:
AWS_REGION: 'eu-central-1'
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.PRODUCTION_CLOUDFRONT_DISTRIBUTION_ID }}
- run: yarn run build
if: ${{ github.ref == 'refs/heads/staging' }}
env:
CI: true
DEPLOY_S3_BUCKET_NAME: 'brightinventions-pl-website-content-staging'
GATSBY_ACTIVE_ENV: staging
GATSBY_SITE_URL: 'https://staging.brightinventions.pl/'
GATSBY_CPU_COUNT: 1
GATSBY_PARTYTOWN_ENABLED: ${{ inputs.partytownEnabled || 'false' }}
# Enable for debugging
# - name: Archive public folder
# uses: actions/upload-artifact@v3
# with:
# name: public
# path: public
- run: yarn run deploy-s3
if: ${{ github.ref == 'refs/heads/staging' }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.STAGING_CLOUDFRONT_DISTRIBUTION_ID }}
GATSBY_SITE_URL: 'https://staging.brightinventions.pl/'
DEPLOY_S3_BUCKET_NAME: 'brightinventions-pl-website-content-staging'
GATSBY_ACTIVE_ENV: staging
- run: yarn run invalidate-cf-cache
if: ${{ github.ref == 'refs/heads/staging' }}
env:
AWS_REGION: 'eu-central-1'
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.STAGING_CLOUDFRONT_DISTRIBUTION_ID }}
- name: Save Gatsby Cache
id: gatsby-cache-save
uses: actions/cache/save@v3
with:
path: |
public
.cache
key: ${{ runner.os }}-gatsby-build-v29-${{ github.ref_name }}
- name: Audit URLs using Lighthouse
if: ${{ github.ref == 'refs/heads/gatsby' }}
uses: treosh/lighthouse-ci-action@v10
with:
urls: |
https://brightinventions.pl/
temporaryPublicStorage: true
configPath: ./.github/lighthouse/main-lighthouserc.json
runs: 3
- name: Audit URLs using Lighthouse
if: ${{ github.ref == 'refs/heads/staging' }}
uses: treosh/lighthouse-ci-action@v10
with:
urls: |
https://staging.brightinventions.pl/
temporaryPublicStorage: true
configPath: ./.github/lighthouse/main-lighthouserc.json
runs: 3