-
Notifications
You must be signed in to change notification settings - Fork 2
169 lines (167 loc) · 6.53 KB
/
master.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: CI/CD
on: [push]
jobs:
CI-CD:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v1
# - name: Configure AWS Credentials
# uses: aws-actions/configure-aws-credentials@v1
# with:
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# aws-region: us-east-1
# - name: Identify file changes
# id: file_changes
# uses: trilom/file-changes-action@v1
# with:
# githubToken: ${{ secrets.GITHUB_TOKEN }}
# - name: Obtain Latest AWS Linux 2 AMI id
# run: echo "::set-env name=BASTION_AMI_ID::$(aws ec2 describe-images --owners amazon --filters 'Name=name,Values=amzn2-ami-hvm-2.0.????????.?-x86_64-gp2' 'Name=state,Values=available' --query 'reverse(sort_by(Images, &CreationDate))[:1].ImageId' --output text)"
# - name: Did Terraform change?
# id: terraform
# run: echo "##[set-output name=changed;]$(git diff-tree --no-commit-id --name-only -r ${{ github.sha }} | grep -q '_cloud/_terraform')"
# - name: Terraform Format
# # if: steps.terraform.output.changed
# uses: hashicorp/terraform-github-actions@master
# with:
# tf_actions_working_dir: "_cloud/_terraform"
# tf_actions_subcommand: "fmt"
# tf_actions_version: 0.12.20
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Terraform Init
# # if: steps.terraform.output.changed
# uses: hashicorp/terraform-github-actions@master
# with:
# tf_actions_working_dir: "_cloud/_terraform"
# tf_actions_subcommand: "init"
# tf_actions_version: 0.12.20
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Terraform Validate
# # if: steps.terraform.output.changed
# uses: hashicorp/terraform-github-actions@master
# with:
# tf_actions_working_dir: "_cloud/_terraform"
# tf_actions_subcommand: "validate"
# tf_actions_version: 0.12.20
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# # - name: Terraform Destroy
# # if: steps.terraform.output.changed
# # run: cd _cloud/_terraform && terraform destroy --auto-approve
# # env:
# # TF_VAR_db_master_pass: ${{ secrets.TF_VAR_db_master_pass }}
# - name: Terraform Apply
# # if: steps.terraform.output.changed
# uses: hashicorp/terraform-github-actions@master
# with:
# tf_actions_working_dir: "_cloud/_terraform"
# tf_actions_subcommand: "apply"
# tf_actions_version: 0.12.20
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# TF_VAR_db_master_pass: ${{ secrets.TF_VAR_db_master_pass }}
# TF_VAR_dns_zone_id: ${{ secrets.TF_VAR_dns_zone_id }}
# - name: Save TF Outputs as Environment Variables
# if: success()
# run: |
# echo "::set-env name=BEANSTALK_APP_NAME::$(cd _cloud/_terraform && terraform output beanstalk_app_name)"
# echo "::set-env name=BEANSTALK_ENV_NAME::$(cd _cloud/_terraform && terraform output beanstalk_env_name)"
# echo "::set-env name=AWS_REGION::$(cd _cloud/_terraform && terraform output aws_region)"
- name: Generate build number
if: success()
uses: einaregilsson/build-number@v2
with:
token: ${{secrets.GITHUB_TOKEN}}
- name: Setup Node
if: success()
uses: actions/setup-node@v1
with:
node-version: "12.x"
# - name: Get yarn cache
# if: success()
# id: yarn-cache
# run: echo "::set-output name=dir::$(yarn cache dir)"
# - name: Cache yarn
# if: success()
# uses: actions/cache@v1
# with:
# path: ${{ steps.yarn-cache.outputs.dir }}
# key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
# restore-keys: |
# ${{ runner.os }}-yarn-
# - name: Sync API docs in readme from JSDoc
# if: success()
# run: yarn document-api
# - name: TOC Generator
# if: success()
# uses: technote-space/toc-generator@v2
# with:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Commit README.md
# if: success()
# run: |
# git config --local user.email "action@github.com"
# git config --local user.name "GitHub Action"
# git add README.md
# git commit -m "chore(docs): updated API docs and TOC in README.md (automated)"
# - name: Push README.md
# if: success()
# uses: ad-m/github-push-action@master
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Build
if: success()
run: yarn build
- name: Package
if: success()
run: zip deploy.zip .next package.json next.config.js
- name: Deploy to EB
if: success()
uses: einaregilsson/beanstalk-deploy@v5
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
application_name: $BEANSTALK_APP_NAME
environment_name: $BEANSTALK_ENV_NAME
version_label: $BUILD_NUMBER
region: $AWS_REGION
deployment_package: deploy.zip
- name: Test E2E
if: success()
id: e2e
run: yarn e2e
- name: Audit Lighthouse
if: success()
id: lh
uses: treosh/lighthouse-ci-action@v2
with:
configPath: "./lighthouserc.js"
urls: |
$TEST_URL
$TEST_URL/blog
- name: Save results
uses: actions/upload-artifact@v1
with:
name: lighthouse-results
path: ".lighthouseci"
- name: Save $LAST_SUCCESSFUL_BUILD_NUMBER
if: success()
run: echo "::set-env name=LAST_SUCCESSFUL_BUILD_NUMBER::$BUILD_NUMBER"
- name: Release
if: success()
run: yarn release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Rollback
if: job.steps.e2e.status == failure() || job.steps.lh.status == failure()
uses: einaregilsson/beanstalk-deploy@v5
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
application_name: $BEANSTALK_APP_NAME
environment_name: $BEANSTALK_ENV_NAME
version_label: $LAST_SUCCESSFUL_BUILD_NUMBER
region: $AWS_REGION