Skip to content

Commit

Permalink
[chore][#17]github action CI/CD workflow 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
sejoon00 committed Jul 25, 2024
1 parent fad6cc5 commit 56ce873
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle

name: Gradle Package

on:
pull_request:
branches: ["master"]

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: checkout
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: create application-aws.yml
run:
mkdir ./src/main/resources
cd ./src/main/resources

touch ./application-aws.yml

echo "${{ secrets.YML-AWS }}" >> ./application-aws.yml

cat ./application-aws.yml


- name: build
run: |
chmod +x gradlew
./gradlew build -x test
- name: Docker hub login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_ID }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}


- name: Docker image build
run: |
docker build -t ${{secrets.DOCKERHUB_ID}}/Cheada-spring .
- name: Docker Hub push
run: docker push ${{secrets.DOCKERHUB_ID}}/Cheada-spring

24 changes: 24 additions & 0 deletions .github/workflows/CD.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: deploy-spring-server
on:
push:
branches: master

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy spring MainServer(master)
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SERVER_KEY }}
script: |
cd ~/Desktop/ChaeDa_spring
git fetch origin master
git merge origin/master
./gradlew build
docker rm desktop_back_1 --force
docker rmi desktop_back
cd ..
docker-compose up -d

0 comments on commit 56ce873

Please sign in to comment.