|
| 1 | +name: yappu-world-server-lambda-cd |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + permissions: |
| 12 | + contents: read |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v4 |
| 15 | + |
| 16 | + - name: Set up JDK 17 |
| 17 | + uses: actions/setup-java@v4 |
| 18 | + with: |
| 19 | + java-version: '17' |
| 20 | + distribution: 'corretto' |
| 21 | + cache: gradle |
| 22 | + |
| 23 | + - name: Setup Gradle |
| 24 | + uses: gradle/actions/setup-gradle@v3 |
| 25 | + |
| 26 | + - name: Create .env file |
| 27 | + run: | |
| 28 | + mkdir -p src/main/resources |
| 29 | + echo "DISCORD_SERVER_ALERT_WEBHOOK=${{ secrets.DISCORD_SERVER_ALERT_WEBHOOK }}" > src/main/resources/.env |
| 30 | + cat src/main/resources/.env |
| 31 | +
|
| 32 | + - name: Build ShadowJar |
| 33 | + run: | |
| 34 | + ./gradlew shadowJar |
| 35 | +
|
| 36 | + # Github Action 실행 서버 IP 추출 |
| 37 | + - name: Get Github Actions IP |
| 38 | + id: ip |
| 39 | + |
| 40 | + |
| 41 | + # AWS Credentials |
| 42 | + - name: Configure AWS Credentials |
| 43 | + uses: aws-actions/configure-aws-credentials@v4 |
| 44 | + with: |
| 45 | + aws-access-key-id: ${{ secrets.AWS_BOT_ACCESS_KEY }} |
| 46 | + aws-secret-access-key: ${{ secrets.AWS_BOT_SECRET_KEY }} |
| 47 | + aws-region: ap-northeast-2 |
| 48 | + |
| 49 | + - name: Deploy to AWS Lambda |
| 50 | + run: | |
| 51 | + aws lambda update-function-code \ |
| 52 | + --function-name sendSentryAlertsToDiscord \ |
| 53 | + --zip-file fileb://build/libs/yappu-world-server-lambda-shadow.jar |
| 54 | +
|
| 55 | + # Discord Notification |
| 56 | + - name: CD Success Notification |
| 57 | + uses: sarisia/actions-status-discord@v1 |
| 58 | + if: success() |
| 59 | + with: |
| 60 | + title: ✅ Lambda 배포 성공 ✅ |
| 61 | + webhook: ${{ secrets.DISCORD_SERVER_WEBHOOK }} |
| 62 | + color: 0x00FF00 |
| 63 | + username: 페페훅 |
| 64 | + |
| 65 | + - name: CD Failure Notification |
| 66 | + uses: sarisia/actions-status-discord@v1 |
| 67 | + if: failure() |
| 68 | + with: |
| 69 | + title: ❗️Lambda 배포 실패 ❗️ |
| 70 | + webhook: ${{ secrets.DISCORD_SERVER_WEBHOOK }} |
| 71 | + color: 0xFF0000 |
| 72 | + username: 페페훅 |
0 commit comments