-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,4 +37,4 @@ out/ | |
.vscode/ | ||
|
||
### Kotlin ### | ||
.kotlin | ||
.kotlin |