-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[All] 리뷰미 운영서버 배포 v1.0.0
- Loading branch information
Showing
449 changed files
with
24,031 additions
and
0 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,50 @@ | ||
name: Build test with Gradle | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
paths: | ||
- 'backend/**' | ||
pull_request: | ||
branches: | ||
- develop | ||
paths: | ||
- 'backend/**' | ||
|
||
jobs: | ||
build: | ||
permissions: | ||
contents: read | ||
issues: read | ||
checks: write | ||
pull-requests: write | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout to current repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup JDK Corretto using cached gradle dependencies | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'corretto' | ||
java-version: 17 | ||
cache: 'gradle' | ||
|
||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@v3 | ||
with: | ||
gradle-version: 8.8 | ||
|
||
- name: Build and test with gradle | ||
run: | | ||
cd ./backend | ||
./gradlew test | ||
- name: Publish test results | ||
uses: EnricoMi/publish-unit-test-result-action@v2 | ||
if: always() | ||
with: | ||
files: | | ||
./backend/build/test-results/**/*.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,98 @@ | ||
name: "[DEVELOP] CD using Github self-hosted runner" | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- develop | ||
paths: | ||
- 'backend/**' | ||
|
||
env: | ||
ARTIFACT_NAME: review-me-dev | ||
ARTIFACT_DIRECTORY: ./backend/build/libs | ||
APPLICATION_DIRECTORY: ~/review-me-app | ||
|
||
jobs: | ||
build: | ||
name: Build Jar file and upload artifact | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout to current repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup JDK Corretto using cached gradle dependencies | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'corretto' | ||
java-version: 17 | ||
cache: 'gradle' | ||
|
||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@v3 | ||
with: | ||
gradle-version: 8.8 | ||
|
||
- name: Build and test with gradle | ||
run: | | ||
cd ./backend | ||
./gradlew clean bootJar | ||
- name: Rename artifact file | ||
run: | | ||
mv ${{ env.ARTIFACT_DIRECTORY }}/*.jar ${{ env.ARTIFACT_DIRECTORY }}/${{ env.ARTIFACT_NAME }}.jar | ||
- name: Upload created artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ env.ARTIFACT_NAME }} | ||
path: ${{ env.ARTIFACT_DIRECTORY }}/${{ env.ARTIFACT_NAME }}.jar | ||
|
||
deploy: | ||
name: Deploy via self-hosted runner | ||
needs: build | ||
runs-on: [self-hosted, dev] | ||
|
||
steps: | ||
- name: Checkout to secret repository | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: ${{ secrets.PRIVATE_REPOSITORY_URL }} | ||
token: ${{ secrets.PRIVATE_REPOSITORY_TOKEN }} | ||
|
||
- name: Download uploaded artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{ env.ARTIFACT_NAME }} | ||
|
||
- name: Copy application related files to other directory | ||
run: | | ||
sudo mv * ${{ env.APPLICATION_DIRECTORY }} | ||
- name: Find ${{ env.ARTIFACT_NAME }} process | ||
run: | | ||
echo "Checking processes..." | ||
PID=$(pgrep -f ${{ env.ARTIFACT_NAME }}.jar -d " " || true) | ||
if [ -n "$PID" ]; then | ||
echo "Found processes: $PID" | ||
echo "server_running=true" >> "$GITHUB_ENV" | ||
echo "PID=$PID" >> "$GITHUB_ENV" | ||
else | ||
echo "Process not found!" | ||
echo "server_running=false" >> "$GITHUB_ENV" | ||
fi | ||
- name: Stop server if available (gracefully) | ||
if: env.server_running == 'true' | ||
run: | | ||
echo "Gracefully shutting down process ${{ env.PID }}" | ||
for PID in ${{ env.PID }}; do | ||
sudo kill -15 $PID | true | ||
tail --pid=$PID -f /dev/null | true | ||
done | ||
- name: Start server | ||
run: | | ||
cd ${{ env.APPLICATION_DIRECTORY }} | ||
sudo nohup java -jar ${{ env.ARTIFACT_NAME }}.jar --server.port=8080 --spring.config.location=application-dev.yml & |
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,98 @@ | ||
name: "[RELEASE] CD using Github self-hosted runner" | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- release | ||
paths: | ||
- 'backend/**' | ||
|
||
env: | ||
ARTIFACT_NAME: review-me-prod | ||
ARTIFACT_DIRECTORY: ./backend/build/libs | ||
APPLICATION_DIRECTORY: ~/review-me-app | ||
|
||
jobs: | ||
build: | ||
name: Build Jar file and upload artifact | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout to current repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup JDK Corretto using cached gradle dependencies | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'corretto' | ||
java-version: 17 | ||
cache: 'gradle' | ||
|
||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@v3 | ||
with: | ||
gradle-version: 8.8 | ||
|
||
- name: Build and test with gradle | ||
run: | | ||
cd ./backend | ||
./gradlew clean bootJar | ||
- name: Rename artifact file | ||
run: | | ||
mv ${{ env.ARTIFACT_DIRECTORY }}/*.jar ${{ env.ARTIFACT_DIRECTORY }}/${{ env.ARTIFACT_NAME }}.jar | ||
- name: Upload created artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ env.ARTIFACT_NAME }} | ||
path: ${{ env.ARTIFACT_DIRECTORY }}/${{ env.ARTIFACT_NAME }}.jar | ||
|
||
deploy: | ||
name: Deploy via self-hosted runner | ||
needs: build | ||
runs-on: [self-hosted, prod] | ||
|
||
steps: | ||
- name: Checkout to secret repository | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: ${{ secrets.PRIVATE_REPOSITORY_URL }} | ||
token: ${{ secrets.PRIVATE_REPOSITORY_TOKEN }} | ||
|
||
- name: Download uploaded artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{ env.ARTIFACT_NAME }} | ||
|
||
- name: Copy application related files to other directory | ||
run: | | ||
sudo mv * ${{ env.APPLICATION_DIRECTORY }} | ||
- name: Find ${{ env.ARTIFACT_NAME }} process | ||
run: | | ||
echo "Checking processes..." | ||
PID=$(pgrep -f ${{ env.ARTIFACT_NAME }}.jar -d " " || true) | ||
if [ -n "$PID" ]; then | ||
echo "Found processes: $PID" | ||
echo "server_running=true" >> "$GITHUB_ENV" | ||
echo "PID=$PID" >> "$GITHUB_ENV" | ||
else | ||
echo "Process not found!" | ||
echo "server_running=false" >> "$GITHUB_ENV" | ||
fi | ||
- name: Stop server if available (gracefully) | ||
if: env.server_running == 'true' | ||
run: | | ||
echo "Gracefully shutting down process ${{ env.PID }}" | ||
for PID in ${{ env.PID }}; do | ||
sudo kill -15 $PID | true | ||
tail --pid=$PID -f /dev/null | true | ||
done | ||
- name: Start server | ||
run: | | ||
cd ${{ env.APPLICATION_DIRECTORY }} | ||
sudo nohup java -jar ${{ env.ARTIFACT_NAME }}.jar --server.port=8080 --spring.config.location=application-prod.yml & |
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,106 @@ | ||
name: Mention Discord on Pull Request Review | ||
|
||
on: | ||
pull_request_review: | ||
types: [ submitted ] | ||
|
||
env: | ||
"31026350": "206298119661420544" | ||
"64690761": "243991296060948491" | ||
"69838872": "1165830186990850110" | ||
"111052302": "859318944195149855" | ||
"145949635": "1164111111193366580" | ||
"76177848": "710749110570975243" | ||
"110809927": "971312723260493834" | ||
"80167893": "1162754699099906169" | ||
"backend": "1263405654534525051" | ||
"frontend": "1263406763382931467" | ||
|
||
jobs: | ||
notify-on-pr: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Find prefix for PR title | ||
run: | | ||
echo "Finding prefix for PR title" | ||
PR_TITLE='${{ github.event.pull_request.title }}' | ||
PR_PREFIX=$(echo $PR_TITLE | cut -d ' ' -f1) | ||
if [ "$PR_PREFIX" = '[BE]' ]; then | ||
echo Backend PR Found! | ||
echo "PR_PREFIX=BE" >> $GITHUB_ENV | ||
elif [ "$PR_PREFIX" = '[FE]' ]; then | ||
echo Frontend PR Found! | ||
echo "PR_PREFIX=FE" >> $GITHUB_ENV | ||
elif [ "$PR_PREFIX" = '[All]' ]; then | ||
echo All PR Found! | ||
echo "PR_PREFIX=All" >> $GITHUB_ENV | ||
fi | ||
echo PR Prefix : $PR_PREFIX | ||
echo PR Prefix on env : ${{ env.PR_PREFIX }} | ||
- name: Notify on PR Review | ||
if: github.event.review.state == 'approved' || github.event.review.state == 'changes_requested' | ||
run: | | ||
echo "Notify on Discord" | ||
PR_URL='${{ github.event.pull_request.html_url }}' | ||
PR_TITLE='${{ github.event.pull_request.title }}' | ||
PR_AUTHOR='${{ github.event.pull_request.user.login }}' | ||
REVIEWER='${{ github.event.review.user.login }}' | ||
REVIEWER_DISCORD_ID='${{ env[github.event.review.user.id] }}' | ||
AUTHOR_DISCORD_ID='${{ env[github.event.pull_request.user.id] }}' | ||
if [ "${{ env.PR_PREFIX }}" = 'BE' ]; then | ||
WEBHOOK_URL=${{ secrets.DISCORD_BE_PR_WEBHOOK_URL }} | ||
elif [ "${{ env.PR_PREFIX }}" = 'FE' ]; then | ||
WEBHOOK_URL=${{ secrets.DISCORD_FE_PR_WEBHOOK_URL }} | ||
elif [ "${{ env.PR_PREFIX }}" = 'All' ]; then | ||
WEBHOOK_URL=${{ secrets.DISCORD_ALL_PR_WEBHOOK_URL }} | ||
fi | ||
if [ "${{ github.event.review.state }}" = 'approved' ]; then | ||
COMMENT="PR Approved 되었습니다 🚀" | ||
COLOR=65305 | ||
elif [ "${{ github.event.review.state }}" = 'changes_requested' ]; then | ||
COMMENT="PR에 수정 요구사항이 있습니다 👀" | ||
COLOR=16736293 | ||
else | ||
echo "Invalid review state" | ||
exit 0 | ||
fi | ||
JSON_FILE=$(mktemp) | ||
cat > $JSON_FILE <<EOF | ||
{ | ||
"content": "<@$AUTHOR_DISCORD_ID> $COMMENT", | ||
"embeds": [ | ||
{ | ||
"author": { | ||
"name": "$PR_AUTHOR", | ||
"icon_url": "https://github.com/$PR_AUTHOR.png" | ||
}, | ||
"title": "$PR_TITLE", | ||
"url": "$PR_URL", | ||
"color": $COLOR, | ||
"footer": { | ||
"text": "2024-review-me" | ||
}, | ||
"fields": [ | ||
{ | ||
"name": "리뷰어", | ||
"value": "<@$REVIEWER_DISCORD_ID>", | ||
"inline": true | ||
} | ||
], | ||
"timestamp": "$(date -u +'%Y-%m-%dT%H:%M:%SZ')" | ||
} | ||
] | ||
} | ||
EOF | ||
cat $JSON_FILE | ||
curl -X POST -H 'Content-type: application/json' \ | ||
--data @$JSON_FILE \ | ||
$WEBHOOK_URL | ||
rm $JSON_FILE |
Oops, something went wrong.