Skip to content

Commit

Permalink
#64 [ENV] : cd test
Browse files Browse the repository at this point in the history
  • Loading branch information
hye-on committed Apr 19, 2024
1 parent 9d92572 commit e465713
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/cicd_dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: TogetUp-Server-Dev CI/CD
on:
push:
branches:[ "main", "env/cd" ]

env:
S3_BUCKET_NAME: togetup-storage
FILE_PATH: /home/ubuntu/app/
FILE_NAME: TogetUp-0.0.1-SNAPSHOT.jar

jobs:
build:
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v3

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

- name: Get CurrentTime
uses: 1466587594/get-current-time@v2
id: current-time
with:
format: YYYY-MM-DDTHH-mm-ss
utcOffset: "+09:00"

- name: Show Current Time
run: echo "CurrentTime=${{steps.current-time.outputs.formattedTime}}"
shell: bash

- name: make application-dev.yml
run: |
#mkdir -p ./src/main/resources
cd ./src/main/resources
touch ./application-dev.yaml
echo "${{ secrets.TOGETUP_PROD_APPLICATION }}" >> ./application-dev.yaml
shell: bash

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

- name: Deploy
uses: easingthemes/[email protected]
with:
REMOTE_HOST: ${{ secrets.EC2_HOST }}
REMOTE_USER: ${{ secrets.EC2_USERNAME }}
SSH_PRIVATE_KEY: ${{ secrets.EC2_SSH_KEY }}
REMOTE_PORT: 22
SOURCE: 'build/libs/${{env.FILE_NAME}}'
TARGET: '${{env.FILE_PATH}}'
SCRIPT_AFTER: |
pid=$(ps aux | grep "${{env.FILE_NAME}}" | grep -v grep | awk '{print $2}')
echo "pid : $pid"
echo "jar : ${{env.FILE_PATH}}${{env.FILE_NAME}}"
if [ -n "$pid" ]; then
kill -9 $pid
fi
nohup java -jar ${{env.FILE_PATH}}${{env.FILE_NAME}} 2>&1 &

0 comments on commit e465713

Please sign in to comment.