Merge pull request #156 from softeerbootcamp4th/feature/155-chore #165
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: CD | |
on: | |
push: | |
branches: [ "dev" ] | |
pull_request: | |
branches: [ "dev" ] | |
types: [closed] | |
workflow_dispatch: | |
permissions: | |
contents: read | |
id-token: write | |
jobs: | |
deploy: | |
if: github.event.pull_request.merged == true | |
runs-on: self-hosted | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Docker Login | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Pull Docker Image | |
run: sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/orange | |
- name: AWS credential | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: ${{ secrets.AWS_ROLE_NAME }} | |
role-session-name: GithubActions | |
aws-region: ${{ secrets.SSM_PARAMETER_REGION }} | |
- name: Get Parameter | |
id: get-parameter | |
run: | | |
sudo aws ssm get-parameter --name ${{ secrets.SSM_PARAMETER_NAME }} --with-decryption --region ${{ secrets.SSM_PARAMETER_REGION }} --query "Parameter.Value" --output text > .env | |
- name: Deploy with Docker Compose | |
run: | | |
cd infra | |
sudo docker-compose --env-file ../.env down | |
sudo docker-compose --env-file ../.env up -d | |
rm -f ../.env | |
sudo docker image prune -f |