-
Notifications
You must be signed in to change notification settings - Fork 1
67 lines (57 loc) · 1.78 KB
/
deploy.yml
File metadata and controls
67 lines (57 loc) · 1.78 KB
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
name: Deploy React App via CodeDeploy
on:
push:
branches:
- main
workflow_dispatch: {}
permissions:
id-token: write
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Get Commit Hash (GITHUB_SHA)
id: commit_hash
run: |
echo "COMMIT_HASH=$GITHUB_SHA" >> $GITHUB_ENV
- name: Install Dependencies
run: |
cd application
npm install
- name: Build React App
run: |
cd application
npm run build
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.IAMROLE_GITHUB }}
role-session-name: GitHub-Action-Role
aws-region: ap-south-1
audience: sts.amazonaws.com
- name: Upload Build to S3
run: |
cd application
zip -r build.zip appspec.yml dist/ scripts/
aws s3 cp build.zip s3://${{ secrets.S3_BUCKET }}/builds/build-$GITHUB_SHA.zip
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.IAMROLE_GITHUB }}
role-session-name: GitHub-Action-Role
aws-region: ap-south-1
audience: sts.amazonaws.com
- name: Deploy to CodeDeploy
run: |
echo "Using Commit Hash: $GITHUB_SHA"
aws deploy create-deployment \
--application-name CodeDeployAppNameWithASG \
--deployment-group-name CodeDeployGroupName \
--s3-location bucket=${{ secrets.S3_BUCKET }},key=builds/build-$GITHUB_SHA.zip,bundleType=zip