Merge pull request #38 from bescka/update-backup-setup #16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 \ |