Skip to content

Commit

Permalink
update deploy.yml (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
endermaru authored Dec 25, 2024
1 parent 8df2a65 commit a9288d2
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
51 changes: 51 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Docker Publish

on:
push:
branches:
- main

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
# 1. Checkout the repository
- name: Checkout repository
uses: actions/checkout@v3

# 2. Log in to Docker Hub
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

# 3. Build and tag the Docker image
- name: Build Docker image
run: |
docker build -t endermaru/22-5-team1-server:latest .
docker tag endermaru/22-5-team1-server:latest endermaru/22-5-team1-server:${{ github.sha }}
# 4. Push the Docker image to Docker Hub
- name: Push Docker image
run: |
docker push endermaru/22-5-team1-server:latest
docker push endermaru/22-5-team1-server:${{ github.sha }}
deploy:
runs-on: ubuntu-latest
needs: build-and-push

steps:
# 1. Deploy to EC2 via SSH
- name: Deploy to EC2
uses: appleboy/[email protected]
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.EC2_PRIVATE_KEY }}
script: |
docker-compose down
docker-compose pull
docker-compose up -d
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ out/
.vscode/

### Kotlin ###
.kotlin
.kotlin

0 comments on commit a9288d2

Please sign in to comment.