-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (47 loc) · 1.62 KB
/
deploy.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
name: Deploy Blog
on:
push:
branches:
- master
repository_dispatch:
types: [update_entry]
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'yarn'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-yarn-
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/WebIdentityForGitHubActions
role-session-name: github-actions-session
aws-region: ap-northeast-1
- name: Install modules
run: yarn install
- name: Build application
run: yarn build
env:
X_MICROCMS_API_KEY: ${{ secrets.X_MICROCMS_API_KEY }}
X_MICROCMS_API_SUB_DOMAIN: ${{ secrets.X_MICROCMS_API_SUB_DOMAIN }}
X_MICROCMS_API_NAME: ${{ secrets.X_MICROCMS_API_NAME }}
- name: Deploy to S3
run: aws s3 sync ./dist/ s3://${{ secrets.S3_BUCKET_ID }}
- name: Create CloudFront invalidation
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*"