Skip to content

Commit

Permalink
feat: Add CI-CD Pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
h-beeen committed Feb 19, 2024
1 parent d26da51 commit a988df8
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: CD

on:
push:
branches:
- 'master'

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
token: ${{ secrets.GIT_TOKEN }}
submodules: true

- name: Setup Java 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'

- name: Update Git submodules
run: git submodule update --remote --recursive

- name: Build and test with Gradle
run: ./gradlew test

- name: Build and push Docker image
run: ./gradlew clean bootBuildImage -PDOCKERHUB_ID=${{ secrets.DOCKERHUB_ID }} -PDOCKERHUB_TOKEN=${{ secrets.DOCKERHUB_TOKEN }}

- name: SSH into EC2 instance
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.NCP_HOST }}
username: ${{ secrets.NCP_USERNAME }}
password: ${{ secrets.NCP_PASSWORD }}
port: ${{ secrets.NCP_SSH_PORT }}
script: |
docker pull ${{ secrets.DOCKER_HUB_URL }}
docker ps -f name=be-server -q | xargs --no-run-if-empty docker container stop
docker ps -a -f name=be-server -q | xargs --no-run-if-empty docker container rm
docker run -d --name be-server -p 80:8080 \
${{ secrets.DEV_DOCKER_HUB_URL }}
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI

on:
pull_request:
push:
branches:
- 'develop'

jobs:
build:
name: "Check Gradle Build"
runs-on: ubuntu-latest
steps:
- name: (Set Up) checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GIT_TOKEN }}
submodules: true

- name: Update Git submodules
run: git submodule update --remote --recursive

- name: (Set Up) Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: (Set Up) Grant Execute permission for gradlew
run: chmod 777 gradlew

- name: (Build) Build with Gradle
run: ./gradlew clean build -i

0 comments on commit a988df8

Please sign in to comment.