-
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
1 parent
23aae10
commit 270f045
Showing
1 changed file
with
53 additions
and
0 deletions.
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,53 @@ | ||
name: build and deploy | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
- name: Run chmod to make gradlew executable | ||
run: chmod +x ./gradlew | ||
- name: Build with Gradle | ||
run : ./gradlew clean build --exclude-task test | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Build Docker | ||
run: docker build --platform linux/amd64 -t ${{ secrets.DOCKERHUB_USERNAME }}/infra_practice_server . | ||
- name: Push Docker | ||
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/infra_practice_server:latest | ||
|
||
|
||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: Docker compose | ||
uses: appleboy/ssh-action@master | ||
with: | ||
username: ubuntu | ||
host: ${{ secrets.INFRA_PRACTICE_SERVER_IP }} | ||
key: ${{ secrets.EC2_SSH_KEY }} | ||
script: | | ||
sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/infra_practice_server:latest | ||
sudo docker run -d -p 8080:8080 --name deploy_container |