use prefixed url for db #30
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: CI/CD for website | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
deploy-site: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- id: install-aws-cli | |
uses: unfor19/install-aws-cli-action@v1 | |
with: | |
version: 2 | |
verbose: true | |
arch: amd64 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_REGION }} | |
- name: Deploy to EC2 via SSM | |
run: | | |
aws ssm send-command \ | |
--document-name "AWS-RunShellScript" \ | |
--targets "Key=instanceids,Values=${{ secrets.EC2_INSTANCE_ID }}" \ | |
--parameters '{ | |
"commands": [ | |
"cd /home/ubuntu/hbd", | |
"sudo git pull", | |
"sudo docker compose -f docker-compose-prod.yml build", | |
"sudo docker stop hbd || true", | |
"sudo docker rm hbd || true", | |
"sudo docker compose -f docker-compose-prod.yml up -d hbd" | |
] | |
}' \ | |
--comment "Deploying new version of hbd" |