Skip to content

Merge pull request #10 from Project-Catcher/githubaction #1

Merge pull request #10 from Project-Catcher/githubaction

Merge pull request #10 from Project-Catcher/githubaction #1

Workflow file for this run

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
name: Java CI with Gradle
on:
push:
branches: [ "main" ]
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: ubuntu-latest
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
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 }}:catcher-service
docker push ${{ env.ecr_url }}:catcher-service
- 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 }}