Skip to content

Commit

Permalink
๐Ÿ—‚๏ธ:: (#main) cd
Browse files Browse the repository at this point in the history
  • Loading branch information
tedsoftj1123 authored Sep 26, 2023
1 parent 0d81ad9 commit 93ac9c7
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions .github/workflows/CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,21 @@ jobs:
- name: Build with Gradle
run: ./gradlew --build-cache build

- name: Login to Dockerhub
uses: docker/login-action@v1
- name: Login to ECR
id: ecr
uses: elgohr/ecr-login-action@master
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
access_key: ${{ secrets.AWS_ACCESS }}
secret_access_key: ${{ secrets.AWS_SECRET }}
region: ${{ secrets.AWS_REGION }}

- name: Docker Build
run: docker build -t ${{ secrets.DOCKER_IMAGE }} .

- name: Push on Dockerhub
run: docker push ${{ secrets.DOCKER_IMAGE }}
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: ${{ secrets.ECR_REPOSITORY }}
username: ${{ steps.ecr.outputs.username }}
password: ${{ steps.ecr.outputs.password }}
registry: ${{ steps.ecr.outputs.registry }}

- name: Connect EC2 & Deploy Docker Image
uses: appleboy/ssh-action@master
Expand All @@ -44,10 +48,11 @@ jobs:
key: ${{ secrets.EC2_KEY }}
script: |
cd jobis
docker pull ${{ secrets.DOCKER_IMAGE }}
aws ecr get-login-password --region ${{ secrets.AWS_REGION }} | docker login --username AWS --password-stdin ${{ secrets.ECR_REPOSITORY }}
docker pull ${{ secrets.ECR_REPOSITORY }}
docker rm -f jobis-server
docker image prune -a -f
docker run --name jobis-server -dp 8080:8080 --env-file .env ${{ secrets.DOCKER_IMAGE }}
docker run --name jobis-server -dp 8080:8080 --env-file .env ${{ secrets.ECR_REPOSITORY }}

0 comments on commit 93ac9c7

Please sign in to comment.