Skip to content

chore: 깃허브 액션 워크플로우 작성 (#1) #1

chore: 깃허브 액션 워크플로우 작성 (#1)

chore: 깃허브 액션 워크플로우 작성 (#1) #1

Workflow file for this run

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