Skip to content

Commit

Permalink
chore: CICD 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
nohy6630 committed May 3, 2024
1 parent 93cb9b2 commit 70a22bd
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: CI CD

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]

- name: Setup Java JDK
uses: actions/[email protected]
with:
java-version: '17'
distribution: 'temurin'

- name: Cache
uses: actions/[email protected]
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Grant execute permission for gradlew
run: chmod u+x gradlew

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

- name: Build and push Docker image
env:
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
run: |
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
docker build -t $DOCKER_USERNAME/alarm .
docker push $DOCKER_USERNAME/alarm
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]

- name: SSH Remote Commands
uses: appleboy/[email protected]
with:
host: ${{secrets.EC2_HOST}}
username: ubuntu
key: ${{secrets.EC2_PRIVATE_KEY}}
port: 22
script: |
sudo docker-compose down
sudo chmod 777 ./deploy.sh
sudo ./deploy.sh
sudo docker image prune -f

0 comments on commit 70a22bd

Please sign in to comment.