-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (42 loc) · 1.5 KB
/
deploy_on_push.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
name: Deploy on Push
# test change
# another test change
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Configure AWS credentials from Github OIDC
uses: aws-actions/configure-aws-credentials@v3
with:
role-to-assume: ${{secrets.ROLE_TO_ASSUME}}
aws-region: ${{secrets.AWS_REGION}}
- name: Pull latest code on remote server
run: |
aws ssm send-command \
--instance-ids ${{secrets.AWS_INSTANCE_ID}} \
--document-name "AWS-RunShellScript" \
--comment "Pull latest code" \
--parameters 'commands=cd ${{ secrets.WORK_DIR }} && && git checkout main && git pull' \
--timeout-seconds 60 \
- name: Manage Docker Compose on remote server
run: |
aws ssm send-command \
--instance-ids ${{secrets.AWS_INSTANCE_ID}} \
--document-name "AWS-RunShellScript" \
--comment "Manage Docker Compose" \
--parameters 'commands=cd ${{ secrets.WORK_DIR }} && \
docker-compose down && \
docker rmi file_uploader-backend:latest || true && \
docker rmi file_uploader-frontend:latest || true && \
docker-compose pull && \
docker-compose up -d' \
--timeout-seconds 60 \