|
| 1 | +name: Deploy Registry |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - 'packages/registry/src/**' |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +jobs: |
| 11 | + deploy: |
| 12 | + name: Deploy to Lambda |
| 13 | + runs-on: ubuntu-latest |
| 14 | + permissions: |
| 15 | + contents: read |
| 16 | + |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v6 |
| 19 | + |
| 20 | + - name: Setup Bun |
| 21 | + uses: oven-sh/setup-bun@v2 |
| 22 | + with: |
| 23 | + bun-version: latest |
| 24 | + |
| 25 | + - name: Build Lambda bundle |
| 26 | + run: | |
| 27 | + cd packages/registry |
| 28 | + bun build src/lambda.ts --outfile dist/lambda.mjs --target node --minify |
| 29 | + cd dist && zip -j lambda.zip lambda.mjs |
| 30 | + echo "Bundle size: $(wc -c < lambda.zip) bytes" |
| 31 | +
|
| 32 | + - name: Deploy to AWS Lambda |
| 33 | + env: |
| 34 | + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 35 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 36 | + AWS_REGION: us-east-1 |
| 37 | + run: | |
| 38 | + aws lambda update-function-code \ |
| 39 | + --function-name pantry-registry \ |
| 40 | + --zip-file fileb://packages/registry/dist/lambda.zip \ |
| 41 | + --region us-east-1 \ |
| 42 | + --query 'LastModified' --output text |
| 43 | +
|
| 44 | + - name: Verify deployment |
| 45 | + run: | |
| 46 | + sleep 5 |
| 47 | + HTTP_CODE=$(curl -sS -o /dev/null -w '%{http_code}' \ |
| 48 | + 'https://registry.pantry.dev/health' \ |
| 49 | + --max-time 15 2>/dev/null) || true |
| 50 | + echo "Health check: HTTP $HTTP_CODE" |
| 51 | + if [ "$HTTP_CODE" != "200" ]; then |
| 52 | + echo "::warning::Health check returned $HTTP_CODE (custom domain may not be configured yet)" |
| 53 | + fi |
| 54 | +
|
| 55 | + notify: |
| 56 | + name: Discord notification |
| 57 | + needs: deploy |
| 58 | + if: always() |
| 59 | + runs-on: ubuntu-latest |
| 60 | + steps: |
| 61 | + - uses: actions/checkout@v6 |
| 62 | + - uses: ./.github/actions/discord-notify |
| 63 | + with: |
| 64 | + title: "Registry Deploy — ${{ needs.deploy.result == 'success' && 'Deployed' || needs.deploy.result == 'cancelled' && 'Cancelled' || 'Failed' }}" |
| 65 | + description: "Registry Lambda function updated" |
| 66 | + status: ${{ needs.deploy.result == 'success' && 'success' || needs.deploy.result == 'cancelled' && 'warning' || 'failure' }} |
| 67 | + fields: | |
| 68 | + [ |
| 69 | + {"name": "Branch", "value": "${{ github.ref_name }}", "inline": true}, |
| 70 | + {"name": "Actor", "value": "${{ github.actor }}", "inline": true} |
| 71 | + ] |
| 72 | + webhook_url: ${{ secrets.DISCORD_WEBHOOK_URL }} |
0 commit comments