-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (123 loc) · 4.83 KB
/
ci.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
name: CI
on:
push:
branches:
- 'master'
- 'next'
- 'v3.x'
permissions:
packages: write
contents: write
id-token: write
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
env:
PRODUCT: toolbox
CI: false
environment:
name: toolbox
url: https://toolbox.dev.orfium.xyz
steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v2
with:
node-version: '20.8.1'
- name: Install dependencies and build app
run: |
yarn
yarn documentation:build
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.DEV_CD_USER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DEV_CD_USER_AWS_SECRET_ACCESS_KEY }}
aws-region: "us-east-1"
- name: Check deployment existence
# if: (github.ref == 'refs/heads/master')
id: check-stack-existence
run: |
if aws cloudformation describe-stacks --stack-name ${{ env.PRODUCT }}; then
echo "::set-output name=stack_exists::1";
else
echo "::set-output name=stack_exists::0";
fi
- name: Set up S3-Cloudfront
# if: (github.ref == 'refs/heads/master') && steps.check-stack-existence.outputs.stack_exists == '0'
if: steps.check-stack-existence.outputs.stack_exists == '0'
id: review-app-setup
uses: aws-actions/[email protected]
with:
name: "${{ env.PRODUCT }}"
role-arn: "arn:aws:iam::102867326982:role/OrfiumCloudFormationExecRole"
template: >-
https://orfium-cf-templates.s3.amazonaws.com/aws-cloudfront-s3-frontend.yml
parameter-overrides: >-
CSPHeaderValue=${{ env.CSP_HEADER }},
FeDomainName=${{ env.PRODUCT }}.dev.orfium.xyz,
CreateDNSRecord=true,
HostedZoneName=dev.orfium.xyz,
TLSCertificateArn=arn:aws:acm:us-east-1:102867326982:certificate/a944c841-aaa5-4612-b58c-a27630b335e5
no-fail-on-empty-changeset: "1"
tags: >
[
{"Key": "Name", "Value": "review-frontend"},
{"Key": "info:creator", "Value": "github-actions"},
{"Key": "info:maintainer", "Value": "devops.dpt"},
{"Key": "info:product", "Value": "${{ env.PRODUCT }}"},
{"Key": "info:env", "Value": "test"}
]
- name: Push to Production - invalidate cache
run: |
S3_BUCKET_NAME=$(aws cloudformation describe-stacks --stack-name "${{ env.PRODUCT }}" --query 'Stacks[0].Outputs[?OutputKey==`S3BucketName`].OutputValue' --output text)
DISTRIBUTION_ID=$(aws cloudformation describe-stacks --stack-name "${{ env.PRODUCT }}" --query 'Stacks[0].Outputs[?OutputKey==`FeCloudFrontDistributionId`].OutputValue' --output text)
INVALIDATION_ID=`aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths "/*" | jq -r .Invalidation.Id`
aws s3 sync documentation/build/ s3://${S3_BUCKET_NAME}/
aws cloudfront wait invalidation-completed --distribution-id $DISTRIBUTION_ID --id $INVALIDATION_ID
- name: Release
env:
GITHUB_NPM_CONFIG_REGISTRY: 'https://npm.pkg.github.com/'
GITHUB_NPM_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PUBLIC_NPM_CONFIG_REGISTRY: 'https://registry.npmjs.org'
PUBLIC_NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
deploy-docs:
if: github.ref == 'refs/heads/master'
name: Deploy Docs
runs-on: ubuntu-latest
needs: deploy
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v2
with:
node-version: '20.8.1'
- name: Install dependencies
run: yarn install
- name: Generate docs
run: yarn documentation:generate
- name: Clone docs repo
uses: actions/checkout@v2
with:
fetch-depth: 0
repository: Orfium/docs
path: docs-repo
ssh-key: ${{ secrets.DOCS_DEPLOY_KEY }}
- name: Copy and commit docs
run: |
rm -rf $GITHUB_WORKSPACE/docs-repo/${GITHUB_REPOSITORY#*/}
mkdir -p $GITHUB_WORKSPACE/docs-repo/${GITHUB_REPOSITORY#*/}
cp -r typeDocs/* $GITHUB_WORKSPACE/docs-repo/${GITHUB_REPOSITORY#*/}/
cd $GITHUB_WORKSPACE/docs-repo/
git config --global user.email "[email protected]"
git config --global user.name "orfium-org"
git add .
git commit -m "Update ${GITHUB_REPOSITORY#*/} docs"
git push origin master