Skip to content

Commit

Permalink
Merge pull request #20 from YAPP-Github/feat/ISSUE-15
Browse files Browse the repository at this point in the history
feat: CD pipeline
  • Loading branch information
Seokyeong237 authored Jan 19, 2024
2 parents dfbb964 + 856a3c3 commit 9d0c7ac
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ jobs:
- name: Build with Gradle
run: ./gradlew clean build -x test

# zip 파일로 압축
- name: zip file
run: zip -r fullcar.zip ./scripts ./appspec.yml ./build/libs/*.jar

# AWS 자격 증명
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
Expand All @@ -48,8 +52,7 @@ jobs:
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY_NAME }}
IMAGE_TAG: ${{ github.sha }}
run: |
docker buildx build --platform=linux/amd64 -t $ECR_REGISTRY/$ECR_REPOSITORY .
docker push $ECR_REGISTRY/$ECR_REPOSITORY
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY"
docker push $ECR_REGISTRY/$ECR_REPOSITORY
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY"
19 changes: 19 additions & 0 deletions appspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: 0.0
os: linux

files:
- source: /
destination: /home/ubuntu/deploy
overwrite: yes

permissions:
- object: /home/ubuntu
pattern: '**'
owner: ubuntu
group: ubuntu

hooks:
AfterInstall:
- location: scripts/deploy.sh
timeout: 300
runas: ubuntu
6 changes: 6 additions & 0 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source ~/.bashrc
$(aws ecr get-login --region ap-northeast-2 --no-include-email)
sudo docker rm -f codedeploy
sudo docker rmi "$ECR_REPOSITORY"
sudo docker pull "$ECR_REPOSITORY"
sudo docker run -d --name codedeploy -p 8080:80 "$ECR_REPOSITORY"

0 comments on commit 9d0c7ac

Please sign in to comment.