-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from wanniDev/main
Continuous Delivery Task 추가
- Loading branch information
Showing
7 changed files
with
66 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,27 +27,34 @@ jobs: | |
steps: | ||
- name: checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: set up ssh | ||
uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ secrets.APP_RUNNER_PRIVATE_KEY }} | ||
|
||
- name: SSH to server | ||
run: | | ||
ssh-keyscan -H ${{ secrets.APP_MAIN_SERVER }} >> ~/.ssh/known_hosts | ||
ssh -o StrictHostKeyChecking=no ${{ secrets.APP_RUNNER }}@${{ secrets.APP_MAIN_SERVER }} exit | ||
- name: clone repository | ||
run: ssh nruuner@${{ secrets.APP_MAIN_SERVER }} 'git clone https://github.com/wanniDev/payment-lab' | ||
run: ssh ${{ secrets.APP_RUNNER }}@${{ secrets.APP_MAIN_SERVER }} 'git clone https://github.com/wanniDev/payment-lab' | ||
|
||
- name: Inject property files | ||
run: | | ||
ssh nruuner@${{ secrets.APP_MAIN_SERVER }} 'mkdir -p ./payment-lab/app/src/main/resources/' | ||
ssh nruuner@${{ secrets.APP_MAIN_SERVER }} '[[ ! -f ./payment-lab/app/src/main/resources/application-dev.yml ]] && echo "${{ secrets.APP_PROPS_DEV }}" > ./payment-lab/app/src/main/resources/application-dev.yml' | ||
ssh nruuner@${{ secrets.APP_MAIN_SERVER }} '[[ ! -f ./payment-lab/app/src/main/resources/application-test.yml ]] && echo "${{ secrets.APP_PROPS }}" > ./payment-lab/app/src/main/resources/application-test.yml' | ||
ssh ${{ secrets.APP_RUNNER }}@${{ secrets.APP_MAIN_SERVER }} 'mkdir -p ./payment-lab/app/src/main/resources/' | ||
ssh ${{ secrets.APP_RUNNER }}@${{ secrets.APP_MAIN_SERVER }} '[[ ! -f ./payment-lab/app/src/main/resources/application-dev.yml ]] && echo "${{ secrets.APP_PROPS_DEV }}" > ./payment-lab/app/src/main/resources/application-dev.yml' | ||
ssh ${{ secrets.APP_RUNNER }}@${{ secrets.APP_MAIN_SERVER }} '[[ ! -f ./payment-lab/app/src/main/resources/application-test.yml ]] && echo "${{ secrets.APP_PROPS }}" > ./payment-lab/app/src/main/resources/application-test.yml' | ||
- name: Build application | ||
run: ssh nruuner@${{ secrets.APP_MAIN_SERVER }} 'chmod +x ./payment-lab/gradlew; cd ./payment-lab && ./gradlew clean build' | ||
run: ssh ${{ secrets.APP_RUNNER }}@${{ secrets.APP_MAIN_SERVER }} 'chmod +x ./payment-lab/gradlew; cd ./payment-lab && ./gradlew clean build' | ||
|
||
- name: Deploy | ||
run: | | ||
ssh nruuner@${{ secrets.APP_MAIN_SERVER }} 'pid=$(ps axww | grep -v grep | grep "./app/build/libs/app-0.0.1.jar" | awk "{print \$1}"); if [ -n "$pid" ]; then kill -9 $pid; fi' | ||
ssh nruuner@${{ secrets.APP_MAIN_SERVER }} 'mv ./payment-lab/app/build/libs/app-0.0.1.jar ~/' | ||
ssh nruuner@${{ secrets.APP_MAIN_SERVER }} 'nohup java -Dspring.profiles.active=dev -DadminKey=${{ secrets.APP_ADMIN_KEY }} -jar ~/app-0.0.1.jar > /dev/null 2>&1 &' | ||
ssh nruuner@${{ secrets.APP_MAIN_SERVER }} 'echo "Application started"' | ||
ssh ${{ secrets.APP_RUNNER }}@${{ secrets.APP_MAIN_SERVER }} 'ps axww | grep -v grep | grep "app-0.0.1.jar" | awk '{print $1}' | xargs -r sudo kill -9' | ||
ssh ${{ secrets.APP_RUNNER }}@${{ secrets.APP_MAIN_SERVER }} '[[ -f ~/app-0.0.1.jar ]] && rm -rf ~/app-0.0.1.jar' | ||
ssh ${{ secrets.APP_RUNNER }}@${{ secrets.APP_MAIN_SERVER }} 'mv ./payment-lab/app/build/libs/app-0.0.1.jar ~/app-0.0.1.jar' | ||
ssh ${{ secrets.APP_RUNNER }}@${{ secrets.APP_MAIN_SERVER }} 'sudo nohup java -Dspring.profiles.active=dev -DadminKey=${{ secrets.APP_ADMIN_KEY }} -jar ~/app-0.0.1.jar > /dev/null 2>&1 &' | ||
ssh ${{ secrets.APP_RUNNER }}@${{ secrets.APP_MAIN_SERVER }} 'rm -rf ./payment-lab' | ||
ssh ${{ secrets.APP_RUNNER }}@${{ secrets.APP_MAIN_SERVER }} 'echo "Application started"' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: 1 | ||
datasources: | ||
- name: Prometheus | ||
type: prometheus | ||
access: proxy | ||
url: http://prometheus:9090 | ||
isDefault: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
services: | ||
prometheus: | ||
image: prom/prometheus:v2.44.0 | ||
container_name: prometheus | ||
ports: | ||
- "9090:9090" | ||
volumes: | ||
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml | ||
- ./prometheus/data:/data | ||
command: | ||
- '--config.file=/etc/prometheus/prometheus.yml' | ||
- '--storage.tsdb.path=/data' | ||
- '--web.enable-lifecycle' | ||
- '--storage.tsdb.retention.time=20d' | ||
|
||
grafana: | ||
image: grafana/grafana:9.5.2 | ||
container_name: grafana | ||
ports: | ||
- "3000:3000" | ||
restart: unless-stopped | ||
volumes: | ||
- ./grafana/provisioning/datasources:/etc/grafana/provisioning/datasources |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
scrape_configs: | ||
- job_name: 'payment-lab-prod' | ||
metrics_path: '/actuator/prometheus' | ||
scrape_interval: 3s | ||
scheme: https | ||
static_configs: | ||
- targets: ['api.wannidev.com'] | ||
labels: | ||
application: 'payment-lab-prod-label' |