Skip to content

Commit

Permalink
chore: 깃허브 액션 워크플로우 작성 (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sangwook02 committed Jan 5, 2024
1 parent 23aae10 commit 270f045
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/cicd.yml
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

0 comments on commit 270f045

Please sign in to comment.