Skip to content

Commit c81b280

Browse files
committed
add deploy to ec2 process
1 parent 8346940 commit c81b280

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

.github/workflows/deploy.yml

+23
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,26 @@ jobs:
7272
7373
- name: Push Docker image
7474
run: docker push ${{ secrets.DOCKER_HUB_USERNAME }}/githubactionstudy:latest
75+
76+
deploy:
77+
name: Deploy to EC2
78+
runs-on: ubuntu-latest
79+
needs: push
80+
steps:
81+
- name: Checkout the repo
82+
uses: actions/checkout@v4
83+
84+
- name: Deploy to EC2
85+
uses: appleboy/ssh-action@master
86+
with:
87+
host: ${{ secrets.AWS_EC2_HOST }}
88+
username: ubuntu
89+
key: ${{ secrets.AWS_EC2_SSH_KEY }}
90+
script: |
91+
echo "${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}" | docker login --username ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
92+
cd /home/ubuntu
93+
export SECRET_VALUE=${{ secrets.SECRET_VALUE}}
94+
docker-compose down || true
95+
docker rm -f hobbyweekly-dev || true
96+
docker-compose pull app
97+
docker-compose up -d

0 commit comments

Comments
 (0)