Skip to content

Commit

Permalink
feat: [#14] GitHub Actions 의 workflows 파일 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
rxdcxdrnine committed May 25, 2022
1 parent 983a6b7 commit 14fdb84
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 0 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Build and Deploy of Continuous Deployment

on:
pull_request:
branches: [ backend-dev ]
types: [ closed ]

permissions:
contents: read

jobs:
build:
if: github.event.pull_request.merged
runs-on: ubuntu-latest

defaults:
run:
working-directory: ./backend

steps:
## gradle tasks
- uses: actions/checkout@v3

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew clean build -x test

## docker tasks
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v3
with:
context: ./backend
push: true
tags: rxdcxdrnine/airbnb:latest

deploy:
if: github.event.pull_request.merged
needs: build
runs-on: ubuntu-latest

steps:
- name: Docker Pull and Run on EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_SSH_KEY }}
script: |
sudo docker pull rxdcxdrnine/airbnb:latest
sudo docker stop airbnb-server && sudo docker rm airbnb-server
sudo docker run -d --name airbnb-server -p 8080:8080 rxdcxdrnine/airbnb:latest
34 changes: 34 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build and Test for Continuous Integration

on:
pull_request:
branches: [ backend-dev ]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest

defaults:
run:
working-directory: ./backend

steps:
- uses: actions/checkout@v3

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew clean build -x test

- name: Test with Gradle
run: SPRING_PROFILES_ACTIVE=[test] ./gradlew test

0 comments on commit 14fdb84

Please sign in to comment.