-
Notifications
You must be signed in to change notification settings - Fork 1
90 lines (76 loc) · 2.41 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
name: CI/CD for nautible front app
on:
push:
branches: ['develop', 'feature/*', 'hotfix/*']
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
permissions:
id-token: write
contents: read
jobs:
build:
runs-on: ubuntu-latest
environment: develop # for azure oidc
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: setup node
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Cache node modules
uses: actions/cache@v4
with:
path: ./app/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
# AWS
- name: setup env file for aws
run: |
cd $GITHUB_WORKSPACE/app
sed -e "s/\$domain/${{ secrets.AWS_CLOUDFRONT_DOMAIN }}/" .env.auth-sample > .env
- name: Build for aws
env:
CI: false
run: |
cd $GITHUB_WORKSPACE/app
yarn
yarn build
- name: Test for aws
env:
CI: false
run: |
cd $GITHUB_WORKSPACE/app
yarn test
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/nautible-dev-githubactions-static-web-deploy-role
aws-region: ap-northeast-1
- name: deploy to aws s3
run: |
cd $GITHUB_WORKSPACE/app
aws s3 sync ./build s3://${{ secrets.AWS_S3_STATIC_WEB_BUCKET }} --exclude "*.git/*" --delete
# Azure
- name: setup env file for azure
run: |
cd $GITHUB_WORKSPACE/app
sed -e "s/\$domain/${{ secrets.AZURE_FRONTDOOR_DOMAIN }}/" .env.auth-sample > .env
- name: Build for azure
env:
CI: false
run: |
cd $GITHUB_WORKSPACE/app
yarn
yarn build
- name: Azure Login
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: deploy to azure storage account
run: |
cd $GITHUB_WORKSPACE/app
az storage blob upload-batch --account-name nautibledevstaticweb -d '$web' -s ./build --overwrite=True