Skip to content

Commit

Permalink
Merge branch 'refs/heads/develop'
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/pull_request_template.md
#	.github/workflows/prod-server-deployer.yml
#	README.md
#	build.gradle
#	src/main/java/ddingdong/ddingdongBE/common/config/SecurityConfig.java
#	src/main/java/ddingdong/ddingdongBE/common/exception/ErrorMessage.java
#	src/main/java/ddingdong/ddingdongBE/common/exception/ExceptionController.java
#	src/main/java/ddingdong/ddingdongBE/domain/activityreport/controller/ClubActivityReportApiController.java
#	src/main/java/ddingdong/ddingdongBE/domain/activityreport/service/ActivityReportService.java
#	src/main/java/ddingdong/ddingdongBE/domain/club/controller/CentralClubApiController.java
#	src/main/java/ddingdong/ddingdongBE/domain/club/controller/dto/response/ClubMemberResponse.java
#	src/main/java/ddingdong/ddingdongBE/domain/club/entity/Club.java
#	src/main/java/ddingdong/ddingdongBE/domain/club/repository/ClubMemberRepository.java
#	src/main/java/ddingdong/ddingdongBE/domain/club/service/ClubMemberService.java
#	src/main/java/ddingdong/ddingdongBE/domain/club/service/ClubService.java
#	src/main/java/ddingdong/ddingdongBE/domain/fileinformation/entity/FileDomainCategory.java
#	src/main/java/ddingdong/ddingdongBE/domain/qrstamp/entity/StampHistory.java
#	src/main/java/ddingdong/ddingdongBE/domain/scorehistory/controller/dto/request/RegisterScoreRequest.java
#	src/main/java/ddingdong/ddingdongBE/domain/scorehistory/controller/dto/response/ScoreHistoryFilterByClubResponse.java
#	src/main/java/ddingdong/ddingdongBE/domain/scorehistory/entity/Score.java
#	src/main/java/ddingdong/ddingdongBE/domain/scorehistory/entity/ScoreHistory.java
#	src/main/java/ddingdong/ddingdongBE/domain/scorehistory/service/ScoreHistoryService.java
#	src/main/resources/application-dev.yml
#	src/main/resources/application.yml
  • Loading branch information
wonjunYou committed Sep 1, 2024
2 parents 306e828 + 16399eb commit 9742db4
Show file tree
Hide file tree
Showing 172 changed files with 5,694 additions and 1,178 deletions.
1 change: 1 addition & 0 deletions .github/codeowners
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @wonjunYou @5uhwann @KoSeonJe
6 changes: 1 addition & 5 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
## 🔥 연관 이슈

- close #이슈번호

## 🚀 작업 내용


## 🤔 고민했던 내용


## 💬 리뷰 중점사항
## 💬 리뷰 중점사항
82 changes: 82 additions & 0 deletions .github/workflows/dev-server-deployer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Develop Server Deployer (CD)

on: workflow_dispatch
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Get Github Actions IP Addresses
id: publicip
run: |
response=$(curl -s canhazip.com)
echo "ip=$response" >> "$GITHUB_OUTPUT"
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
aws-region: 'ap-northeast-2'

- name: Add GitHub Actions IP
run: |
aws ec2 authorize-security-group-ingress \
--group-id ${{ secrets.DEV_EC2_SECURITY_GROUP_ID }} \
--protocol tcp \
--port 22 \
--cidr ${{ steps.publicip.outputs.ip }}/32
- name: Copy Docker Compose file to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.DEV_INSTANCE_HOST }}
username: ${{ secrets.DEV_INSTANCE_USERNAME }}
key: ${{ secrets.DEV_INSTANCE_KEY }}
source: "./compose-dev.yaml"
target: "~/app/docker"
timeout: 120s
overwrite: true

- name: Install Docker if not present
uses: appleboy/[email protected]
with:
host: ${{ secrets.DEV_INSTANCE_HOST }}
username: ${{ secrets.DEV_INSTANCE_USERNAME }}
key: ${{ secrets.DEV_INSTANCE_KEY }}
script: |
if ! command -v docker >/dev/null 2>&1; then
echo "Installing Docker..."
sudo apt-get update
sudo apt-get install -y docker.io
else
echo "Docker already installed."
fi
if ! command -v docker-compose >/dev/null 2>&1; then
echo "Installing Docker Compose..."
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
else
echo "Docker Compose already installed."
fi
- name: Run Docker Compose up
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.DEV_INSTANCE_HOST }}
username: ${{ secrets.DEV_INSTANCE_USERNAME }}
key: ${{ secrets.DEV_INSTANCE_KEY }}
script: |
echo "${{ secrets.DOCKER_PASSWORD }}" | sudo docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
sudo docker-compose -f ~/app/docker/compose-dev.yaml pull
sudo docker-compose -f ~/app/docker/compose-dev.yaml up -d --force-recreate
- name: Remove GitHub Actions IP
run: |
aws ec2 revoke-security-group-ingress \
--group-id ${{ secrets.DEV_EC2_SECURITY_GROUP_ID }} \
--protocol tcp \
--port 22 \
--cidr ${{ steps.publicip.outputs.ip }}/32
63 changes: 63 additions & 0 deletions .github/workflows/dev-server-integrator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Develop Server Integrator (CI)

on:
push:
branches:
- develop

jobs:
build_and_push:
runs-on: ubuntu-latest
steps:
- name: Check Out Repository
uses: actions/checkout@v4

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

- name: Gradle Caching
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: CI Test
run: ./gradlew clean test

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Login to Amazon ECR Public
id: login-ecr-public
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: public

- name: Build, tag, and push docker image to Amazon ECR Public
env:
REGISTRY: ${{ steps.login-ecr-public.outputs.registry }}
REGISTRY_ALIAS: ${{ secrets.DEV_ECR_REGISTRY_ALIAS }}
REPOSITORY: dev-ecr
IMAGE_TAG: latest
run: |
echo "REPOSITORY: $REPOSITORY"
docker build -t $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG .
docker push $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG
echo "::set-output name=image::$REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG"
- name: Logout of Amazon ECR
run: docker logout ${{ env.ECR_REGISTRY }}
105 changes: 105 additions & 0 deletions .github/workflows/dn-rule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: PR Label Automation
on:
schedule:
- cron: '0 10 * * *'

jobs:
update-labels:
runs-on: ubuntu-latest
steps:
- name: Check and Update PR Labels
uses: actions/github-script@v5
with:
script: |
const repo = context.repo;
// Fetch all open PRs
const prs = await github.rest.pulls.list({
owner: repo.owner,
repo: repo.repo,
state: 'open',
});
// Define the Discord webhook URL
const webhookUrl = 'https://discord.com/api/webhooks/1273159249672802304/vU5b6gC9bAHzyLXzWRzV7YqjIVCtO5_gLJ1URonjnbqn45Xa5kixYT1vMWxwLXqFi2y3';
for (const pr of prs.data) {
const prNumber = pr.number;
let labels = pr.labels.map(label => label.name);
// Function to update label
async function updateLabel(oldLabel, newLabel) {
if (oldLabel) {
await github.rest.issues.removeLabel({
owner: repo.owner,
repo: repo.repo,
issue_number: prNumber,
name: oldLabel,
});
}
await github.rest.issues.addLabels({
owner: repo.owner,
repo: repo.repo,
issue_number: prNumber,
labels: [newLabel],
});
}
// Check and update 'D-x' labels
let dLabel = labels.find(label => label.startsWith("D-"));
if (dLabel) {
let day = parseInt(dLabel.split("-")[1]);
if (day > 0) {
const newDayLabel = `D-${day - 1}`;
await updateLabel(dLabel, newDayLabel);
console.log(`Updated label from ${dLabel} to ${newDayLabel} on PR #${prNumber}`);
// Send a notification to Discord
await fetch(webhookUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
username: 'PR Bot',
avatar_url: 'https://avatars.githubusercontent.com/u/9919?s=200&v=4',
embeds: [
{
title: `📢 **PR #${prNumber} - ${pr.title} Review D-${day - 1}** 📢`,
description: `리뷰를 작성해주세요! 리뷰 작성 기간이 ${day - 1}일 남았습니다.`,
url: pr.html_url,
color: 4620980,
footer: {
text: `D-day가 업데이트 되었습니다. ${dLabel} → ${newDayLabel}`
}
}
]
})
});
} else if (day === 0) {
await fetch(webhookUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
username: 'PR Bot',
avatar_url: 'https://avatars.githubusercontent.com/u/9919?s=200&v=4',
embeds: [
{
title: `❗ **PR #${prNumber} - ${pr.title} Review D-0** ❗`,
description: `리뷰 마감일이 지났습니다! 리뷰를 작성해주세요.`,
url: pr.html_url,
color: 4620980,
footer: {
text: `D-day 상태: D-0`
}
}
]
})
});
}
} else {
await updateLabel(null, 'D-3');
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
name: ddingdong-dev-depoly
name: prod-server-deployer

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v1
Expand Down Expand Up @@ -73,7 +72,6 @@ jobs:
- name: Test with Gradle
run: ./gradlew test --no-daemon


- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
Expand Down
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Build stage
FROM gradle:jdk17 AS build
COPY --chown=gradle:gradle . /home/gradle/src
WORKDIR /home/gradle/src
RUN ./gradlew clean build -x test --no-daemon

# Package stage
FROM openjdk:17
COPY --from=build /home/gradle/src/build/libs/*.jar /app.jar
EXPOSE 8080
ENTRYPOINT ["java","-jar","/app.jar"]
Loading

0 comments on commit 9742db4

Please sign in to comment.