Skip to content

Merge pull request #138 from hufscheer/refactor/lineup #112

Merge pull request #138 from hufscheer/refactor/lineup

Merge pull request #138 from hufscheer/refactor/lineup #112

Workflow file for this run

name: Deploy to EC2
on:
push:
branches: [ main ]
jobs:
deploy:
name: Deploy to EC2
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: write env file
run: |
echo "SECRET_KEY=${{ secrets.SECRET_KEY }}" > .env
echo "DB_USER=${{ secrets.DB_USER }}" >> .env
echo "DB_NAME=${{ secrets.DB_NAME }}" >> .env
echo "DB_PASSWORD=${{ secrets.DB_PASSWORD }}" >> .env
echo "DB_HOST=${{ secrets.DB_HOST }}" >> .env
echo "DB_PORT=${{ secrets.DB_PORT }}" >> .env
- name: Set up and build Docker Compose
run: |
sudo apt-get update
sudo apt-get -y install docker-compose
docker-compose build
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
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: make zip file
run: zip -r ./deploy.zip ./appspec.yml ./config/scripts/ ./docker-compose.yml
- name: upload zip file to S3
run: |
aws s3 cp \
--region ap-northeast-2 \
./deploy.zip s3://hufscheer/deploy.zip
- name: Login to Amazon ECR
id : login-ecr
uses : aws-actions/amazon-ecr-login@v1
- name : Build, tag, and push image to Amazon ECR
run : |
docker-compose push
- name: Create CodeDeploy Deployment
id: deploy
run: |
aws deploy create-deployment \
--application-name hufscheer \
--deployment-group-name hufscheer-group \
--deployment-config-name CodeDeployDefault.OneAtATime \
--s3-location bucket=hufscheer,bundleType=zip,key=deploy.zip