-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Revert "Github Actions 배포 workflow 테스트""
- Loading branch information
Showing
9 changed files
with
169 additions
and
286 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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: deploy | ||
|
||
on: | ||
pull_request: | ||
branches: [dev, test/cd] | ||
types: [closed] | ||
|
||
env: | ||
AWS_ACCESS_KEY: ${{ secrets.STG_AWS_ACCESS_KEY }} | ||
AWS_SECRET_KEY: ${{ secrets.STG_AWS_SECRET_KEY }} | ||
AWS_S3_BUCKET_NAME: ${{ secrets.STG_AWS_S3_BUCKET_NAME }} | ||
AWS_S3_REGION: ${{ secrets.STG_AWS_S3_REGION }} | ||
|
||
jobs: | ||
deploy: | ||
|
||
runs-on: ubuntu-latest | ||
if: github.event.pull_request.merged | ||
|
||
steps: | ||
- name: 체크아웃 | ||
uses: actions/checkout@v4 | ||
|
||
- name: JDK 11 설치 | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'corretto' | ||
java-version: '11' | ||
cache: 'gradle' | ||
|
||
- name: Gradle에 실행 권한 부여 | ||
run: chmod +x gradlew | ||
|
||
- name: 빌드 | ||
run: ./gradlew build -x test | ||
|
||
- name: zip 파일 생성 | ||
run: zip -r ./qtudy.zip . | ||
shell: bash | ||
|
||
- name: AWS credentials 설정 | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
aws-access-key-id: $AWS_ACCESS_KEY | ||
aws-secret-access-key: $AWS_SECRET_KEY | ||
aws-region: $AWS_S3_REGION | ||
|
||
- name: S3에 zip 파일 업로드 | ||
run: aws s3 cp \ | ||
--region $AWS_S3_REGION \ | ||
./qtudy.zip s3://$AWS_S3_BUCKET_NAME/qtudy.zip | ||
|
||
- name: Code Deploy 통해 배포 | ||
run: aws deploy create-deployment \ | ||
--application-name $AWS_CODE_DEPLOY_APPLICATION_NAME \ | ||
--file-exists-behavior OVERWRITE \ | ||
--deployment-config-name QtudyStageCodeDeploy \ | ||
--deployment-group-name QtudyStageCodeDeploy-DepGrp \ | ||
--s3-location bucket=$AWS_S3_BUCKET_NAME, bundleType=zip, key=qtudy.zip \ | ||
--region $AWS_S3_REGION | ||
|
||
|
||
|
||
|
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,38 @@ | ||
name: run test | ||
|
||
on: | ||
pull_request: | ||
branches: [main, dev] | ||
types: [opened, synchronize, reopened] | ||
|
||
permissions: | ||
checks: write | ||
pull-requests: write | ||
|
||
jobs: | ||
test: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: 체크아웃 | ||
uses: actions/checkout@v4 | ||
|
||
- name: JDK 11 설치 | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'corretto' | ||
java-version: '11' | ||
cache: 'gradle' | ||
|
||
- name: Gradle에 실행 권한 부여 | ||
run: chmod +x gradlew | ||
|
||
- name: Test 실행 | ||
run: ./gradlew clean test | ||
|
||
- name: Test 결과를 PR에 코멘트로 등록 | ||
uses: EnricoMi/publish-unit-test-result-action@v2 | ||
if: always() | ||
with: | ||
files: '**/build/test-results/test/TEST-*.xml' |
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,21 @@ | ||
version: 0.0 | ||
os: linux | ||
files: | ||
- source: / | ||
destination: /home/ubuntu | ||
overwrite: yes | ||
|
||
permissions: | ||
- object: /home/ubuntu | ||
pattern: "**" | ||
owner: ubuntu | ||
group: ubuntu | ||
|
||
hooks: | ||
BeforeInstall: | ||
- location: scripts/shutdown-prev-application.sh | ||
runas: ubuntu | ||
|
||
AfterInstall: | ||
- location: scripts/build-and-run-new-application.sh | ||
runas: ubuntu |
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,5 @@ | ||
PROJECT_PATH=/home/ubuntu/Qtudy-BE | ||
BUILD_PATH=$PROJECT_PATH/build/libs | ||
BUILD_JAR=$BUILD_PATH/Qtudy-server-0.0.1-SNAPSHOT.jar | ||
|
||
nohup java -jar $BUILD_JAR --spring.profiles.active=stage & |
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 @@ | ||
JAVA_PID=`sudo lsof -i :8080 -t` | ||
if [ -z $JAVA_PID ] | ||
then echo "실행되고 있는 애플리케이션이 없습니다." | ||
else | ||
sudo kill -9 $JAVA_PID | ||
echo "기존에 실행되고 있던 애플리케이션을 종료했습니다." | ||
fi |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.