Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/cicd #17

Merged
merged 12 commits into from
Mar 13, 2024
3 changes: 1 addition & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,8 @@ jobs:
aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }}
aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws configure set region ${{ env.AWS_REGION }}
ECR_REGISTRY_LOGIN=$(aws ecr get-login-password --region ${{ env.AWS_REGION }} | sudo docker login --username AWS --password-stdin ${{ env.ECR_REGISTRY }})
sudo docker rm -f $(docker ps -qa)
sudo docker pull ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}
sudo docker run -d --name dc -p 8080:8080 ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}

sudo docker image prune -f

33 changes: 33 additions & 0 deletions .github/workflows/ssh-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Push to ECR

on:
push:
branches: [ "bug/cicd" ]

env:
AWS_REGION: ap-northeast-2
ECR_REGISTRY: 654654448479.dkr.ecr.ap-northeast-2.amazonaws.com
ECR_REPOSITORY: repick-repo
IMAGE_TAG: 49119eb9a24649b0efd4bac3113fdb6655539606

permissions:
contents: read

jobs:
deploy:
name: CD
runs-on: ubuntu-latest

steps:
- name: Deploy to EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ec2-user
key: ${{ secrets.KEY }}
script: |
sudo docker stop dc
sudo docker rm dc
sudo docker pull ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}
sudo docker run -d --name dc -p 8080:8080 ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}
sudo docker image prune -f