Skip to content

Merge pull request #36 from Project-Catcher/refactor-jdb-gitaction-wo… #15

Merge pull request #36 from Project-Catcher/refactor-jdb-gitaction-wo…

Merge pull request #36 from Project-Catcher/refactor-jdb-gitaction-wo… #15

Workflow file for this run

name: Java CI with Gradle
on:
push:
branches: [ "main", "dev" ]
env:
ECR_URL: ${{ secrets.ECR_REPO_DEV }}
ROLE_ARN: ${{ secrets.OIDC_ROLE }}
AWS_REGION: ${{ secrets.AWS_REGION }}
WEBHOOK_URL: ${{ secrets.WEBHOOK }}
permissions:
id-token: write
contents: read
jobs:
build:
name: Build
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew bootJar
- name: Docker build
run: docker build -t catcher-service .
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ env.AWS_REGION }}
role-session-name: GitHubActions
role-to-assume: ${{ env.ROLE_ARN }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Publish Image to ECR(CATCHER-SERVICE)
run: |
docker tag catcher-service:latest ${{ env.ECR_URL }}:${{ github.sha }}
docker push ${{ env.ECR_URL }}:${{ github.sha }}
- name: Send Notification
if: ${{ always() }}
run: |
if [[ ${{ job.status }} == "success" ]]; then
MESSAGE="✅ ${{ job.status }} 백엔드 ECR 도커파일 업로드 성공: catcher-service - by ${{ github.actor }}"
else
MESSAGE="❌ ${{ job.status }} 백엔드 ECR 도커파일 업로드 실패: catcher-service - by ${{ github.actor }}"
fi
curl -X POST -H "Content-Type: application/json" --data "{\"text\":\"${MESSAGE}\"}" ${{ env.WEBHOOK_URL }}