chore: CI/CD 스크립트 작성 (#1) #1
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
name: yappu-world-server-lambda-cd | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'corretto' | |
cache: gradle | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v3 | |
- name: Create .env file | |
run: | | |
mkdir -p src/main/resources | |
echo "DISCORD_SERVER_ALERT_WEBHOOK=${{ secrets.DISCORD_SERVER_ALERT_WEBHOOK }}" > src/main/resources/.env | |
cat src/main/resources/.env | |
- name: Build ShadowJar | |
run: | | |
./gradlew shadowJar | |
- name: Install AWS CLI | |
run: | | |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" | |
unzip awscliv2.zip | |
sudo ./aws/install | |
# AWS Credentials | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_BOT_ACCESS_KEY }} | |
aws-secret-access-key: ${{ secrets.AWS_BOT_SECRET_KEY }} | |
aws-region: ap-northeast-2 | |
- name: Deploy to AWS Lambda | |
run: | | |
export AWS_PAGER="" | |
aws lambda update-function-code \ | |
--function-name sendSentryAlertsToDiscord \ | |
--zip-file fileb://build/libs/yappu-world-server-lambda-shadow.jar | |
# Discord Notification | |
- name: CD Success Notification | |
uses: sarisia/actions-status-discord@v1 | |
if: success() | |
with: | |
title: ✅ Lambda 배포 성공 ✅ | |
webhook: ${{ secrets.DISCORD_SERVER_WEBHOOK }} | |
color: 0x00FF00 | |
username: 페페훅 | |
- name: CD Failure Notification | |
uses: sarisia/actions-status-discord@v1 | |
if: failure() | |
with: | |
title: ❗️Lambda 배포 실패 ❗️ | |
webhook: ${{ secrets.DISCORD_SERVER_WEBHOOK }} | |
color: 0xFF0000 | |
username: 페페훅 |