Skip to content

Commit cdcdfb4

Browse files
authored
github action
Githubaction
2 parents fe1d18e + 335a939 commit cdcdfb4

File tree

3 files changed

+172
-0
lines changed

3 files changed

+172
-0
lines changed

.github/workflows/cr.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Code Review
2+
3+
permissions:
4+
contents: read
5+
pull-requests: write
6+
7+
env:
8+
WEBHOOK_URL: ${{ secrets.WEBHOOK }}
9+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
10+
11+
on:
12+
pull_request:
13+
types: [opened, reopened, synchronize]
14+
15+
jobs:
16+
code_review:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: anc95/ChatGPT-CodeReview@main
20+
env:
21+
MODEL: gpt-3.5-turbo
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
OPENAI_API_KEY: ${{ env.OPENAI_API_KEY }}
24+
LANGUAGE: Korean
25+
26+
- name: Send Notification
27+
if: ${{ always() }}
28+
run: |
29+
if [[ ${{ job.status }} == "success" ]]; then
30+
MESSAGE="✅ ${{ job.status }} 백엔드 OpenAI 코드 리뷰 성공: batch-service - by ${{ github.actor }}"
31+
else
32+
MESSAGE="❌ ${{ job.status }} 백엔드 OpenAI 코드 리뷰 실패: batch-service - by ${{ github.actor }}"
33+
fi
34+
curl -X POST -H "Content-Type: application/json" --data "{\"text\":\"${MESSAGE}\"}" ${{ env.WEBHOOK_URL }}

.github/workflows/ecr.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Java CI with Gradle
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
7+
env:
8+
ECR_URL: ${{ secrets.ECR_REPO_DEV }}
9+
ROLE_ARN: ${{ secrets.OIDC_ROLE }}
10+
AWS_REGION: ${{ secrets.AWS_REGION }}
11+
WEBHOOK_URL: ${{ secrets.WEBHOOK }}
12+
13+
permissions:
14+
id-token: write
15+
contents: read
16+
17+
jobs:
18+
build:
19+
name: Build
20+
runs-on: ubuntu-latest
21+
22+
permissions:
23+
id-token: write # This is required for requesting the JWT
24+
contents: read # This is required for actions/checkout
25+
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v3
29+
with:
30+
fetch-depth: 1
31+
32+
- name: Set up JDK 17
33+
uses: actions/setup-java@v3
34+
with:
35+
java-version: '17'
36+
distribution: 'temurin'
37+
cache: 'gradle'
38+
39+
- name: Grant execute permission for gradlew
40+
run: chmod +x gradlew
41+
42+
- name: Build with Gradle
43+
run: ./gradlew bootJar
44+
45+
- name: Docker build
46+
run: docker build -t batch-service .
47+
48+
- name: Configure AWS Credentials
49+
uses: aws-actions/configure-aws-credentials@v1
50+
with:
51+
aws-region: ${{ env.AWS_REGION }}
52+
role-session-name: GitHubActions
53+
role-to-assume: ${{ env.ROLE_ARN }}
54+
55+
- name: Login to Amazon ECR
56+
id: login-ecr
57+
uses: aws-actions/amazon-ecr-login@v1
58+
59+
- name: Publish Image to ECR(BATCH-SERVICE)
60+
run: |
61+
docker tag batch-service:latest ${{ env.ECR_URL }}:batch-service
62+
docker push ${{ env.ECR_URL }}:batch-service
63+
64+
- name: Send Notification
65+
if: ${{ always() }}
66+
run: |
67+
if [[ ${{ job.status }} == "success" ]]; then
68+
MESSAGE="✅ ${{ job.status }} 백엔드 ECR 도커파일 업로드 성공: batch-service - by ${{ github.actor }}"
69+
else
70+
MESSAGE="❌ ${{ job.status }} 백엔드 ECR 도커파일 업로드 실패: batch-service - by ${{ github.actor }}"
71+
fi
72+
curl -X POST -H "Content-Type: application/json" --data "{\"text\":\"${MESSAGE}\"}" ${{ env.WEBHOOK_URL }}
73+
74+

.github/workflows/pr.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: CI Test
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
7+
env:
8+
AWS_REGION: ${{ secrets.AWS_REGION }}
9+
AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY_ID }}
10+
AWS_SECRET_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
11+
DEFAULT_OUTPUT: ${{ secrets.AWS_DEFAULT_OUTPUT }}
12+
WEBHOOK_URL: ${{ secrets.WEBHOOK }}
13+
14+
permissions: write-all
15+
16+
jobs:
17+
test_pr:
18+
name: Build and Test
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v3
24+
with:
25+
fetch-depth: 1
26+
27+
- name: Set up AWS CLI
28+
uses: unfor19/install-aws-cli-action@v1
29+
30+
- name: Configure AWS credentials
31+
run: |
32+
aws configure set aws_access_key_id ${{ env.AWS_ACCESS_KEY }}
33+
aws configure set aws_secret_access_key ${{ env.AWS_SECRET_KEY }}
34+
aws configure set default.region ${{ env.AWS_REGION }}
35+
aws configure set default.output ${{ env.DEFAULT_OUTPUT }}
36+
37+
- name: Set up JDK 17
38+
uses: actions/setup-java@v3
39+
with:
40+
java-version: '17'
41+
distribution: 'temurin'
42+
43+
- name: Grant execute permission for gradlew
44+
run: chmod +x gradlew
45+
46+
- name: Test with Gradle
47+
run: ./gradlew --info test
48+
49+
- name: Publish Unit Test Results
50+
uses: EnricoMi/publish-unit-test-result-action@v1
51+
if: ${{ always() }}
52+
with:
53+
github_token: ${{ secrets.GITHUB_TOKEN }}
54+
files: build/test-results/**/*.xml
55+
56+
- name: Send Notification
57+
if: ${{ always() }}
58+
run: |
59+
if [[ ${{ job.status }} == "success" ]]; then
60+
MESSAGE="✅ ${{ job.status }} 백엔드 Unit Test 성공: batch-service - by ${{ github.actor }}"
61+
else
62+
MESSAGE="❌ ${{ job.status }} 백엔드 Unit Test 실패: batch-service - by ${{ github.actor }}"
63+
fi
64+
curl -X POST -H "Content-Type: application/json" --data "{\"text\":\"${MESSAGE}\"}" ${{ env.WEBHOOK_URL }}

0 commit comments

Comments
 (0)