|
| 1 | +name: sentry-notifier-lambda-cd |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +jobs: |
| 9 | + deploy: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - name: Checkout code |
| 13 | + uses: actions/checkout@v4 |
| 14 | + |
| 15 | + - name: Set up JDK 21 |
| 16 | + uses: actions/setup-java@v4 |
| 17 | + with: |
| 18 | + java-version: '21' |
| 19 | + distribution: 'corretto' |
| 20 | + |
| 21 | + - name: Setup Gradle with caching |
| 22 | + uses: gradle/actions/setup-gradle@v3 |
| 23 | + |
| 24 | + - name: Create .env file |
| 25 | + run: | |
| 26 | + mkdir -p src/main/resources |
| 27 | + cat << EOF > src/main/resources/.env |
| 28 | + SLACK_WEBHOOK_CREW_DEV_BE=${{ secrets.SLACK_WEBHOOK_CREW_DEV_BE }} |
| 29 | + SLACK_WEBHOOK_CREW_DEV_FE=${{ secrets.SLACK_WEBHOOK_CREW_DEV_FE }} |
| 30 | + SLACK_WEBHOOK_CREW_PROD_BE=${{ secrets.SLACK_WEBHOOK_CREW_PROD_BE }} |
| 31 | + SLACK_WEBHOOK_CREW_PROD_FE=${{ secrets.SLACK_WEBHOOK_CREW_PROD_FE }} |
| 32 | + EOF |
| 33 | +
|
| 34 | + - name: Build shadow JAR (default = shadowJar) |
| 35 | + run: ./gradlew build |
| 36 | + |
| 37 | + - name: Configure AWS credentials |
| 38 | + uses: aws-actions/configure-aws-credentials@v4 |
| 39 | + with: |
| 40 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 41 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 42 | + aws-region: ap-northeast-2 |
| 43 | + |
| 44 | + - name: Deploy to AWS Lambda |
| 45 | + run: | |
| 46 | + export AWS_PAGER="" |
| 47 | + aws lambda update-function-code \ |
| 48 | + --function-name sentry-notifier \ |
| 49 | + --zip-file fileb://build/libs/sentry-webhook-shadow.jar |
| 50 | +
|
| 51 | + - name: Notify Slack on success |
| 52 | + uses: 8398a7/action-slack@v3 |
| 53 | + if: success() |
| 54 | + with: |
| 55 | + status: custom |
| 56 | + custom_payload: | |
| 57 | + { |
| 58 | + "attachments": [{ |
| 59 | + "color": "good", |
| 60 | + "title": "✅ Lambda 배포 성공", |
| 61 | + "text": "Sentry Notifier Lambda가 성공적으로 배포되었습니다.", |
| 62 | + "fields": [ |
| 63 | + { |
| 64 | + "title": "Workflow Link", |
| 65 | + "value": "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|워크플로우 링크>", |
| 66 | + "short": true |
| 67 | + } |
| 68 | + ] |
| 69 | + }] |
| 70 | + } |
| 71 | + env: |
| 72 | + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CD_WEBHOOK_URL }} |
| 73 | + |
| 74 | + - name: Notify Slack on failure |
| 75 | + uses: 8398a7/action-slack@v3 |
| 76 | + if: failure() |
| 77 | + with: |
| 78 | + status: custom |
| 79 | + custom_payload: | |
| 80 | + { |
| 81 | + "attachments": [{ |
| 82 | + "color": "danger", |
| 83 | + "title": "❌ Lambda 배포 실패", |
| 84 | + "text": "Sentry Notifier Lambda 배포에 실패했습니다.", |
| 85 | + "fields": [ |
| 86 | + { |
| 87 | + "title": "Workflow Link", |
| 88 | + "value": "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|워크플로우 링크>", |
| 89 | + "short": true |
| 90 | + } |
| 91 | + ] |
| 92 | + }] |
| 93 | + } |
| 94 | + env: |
| 95 | + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CD_WEBHOOK_URL }} |
0 commit comments