|
9 | 9 |
|
10 | 10 | jobs: |
11 | 11 | deploy: |
12 | | - name: Deploy to Lambda |
| 12 | + name: Deploy to EC2 |
13 | 13 | runs-on: ubuntu-latest |
14 | 14 | permissions: |
15 | 15 | contents: read |
16 | 16 |
|
17 | 17 | steps: |
18 | 18 | - uses: actions/checkout@v6 |
19 | 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 |
| 20 | + - name: Deploy to registry server |
33 | 21 | 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 |
| 22 | + SSH_PRIVATE_KEY: ${{ secrets.REGISTRY_SSH_KEY }} |
37 | 23 | 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 |
| 24 | + mkdir -p ~/.ssh |
| 25 | + echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa |
| 26 | + chmod 600 ~/.ssh/id_rsa |
| 27 | + ssh-keyscan -H 54.243.196.101 >> ~/.ssh/known_hosts 2>/dev/null |
| 28 | +
|
| 29 | + ssh -o StrictHostKeyChecking=no ec2-user@54.243.196.101 << 'EOF' |
| 30 | + cd /opt/pantry-registry/repo |
| 31 | + git pull origin main |
| 32 | + cd packages/registry |
| 33 | + ~/.bun/bin/bun install --production |
| 34 | + sudo systemctl restart pantry-registry |
| 35 | + sleep 2 |
| 36 | + curl -sf http://localhost:3000/health || echo "Health check failed" |
| 37 | + EOF |
43 | 38 |
|
44 | 39 | - name: Verify deployment |
45 | 40 | run: | |
|
49 | 44 | --max-time 15 2>/dev/null) || true |
50 | 45 | echo "Health check: HTTP $HTTP_CODE" |
51 | 46 | if [ "$HTTP_CODE" != "200" ]; then |
52 | | - echo "::warning::Health check returned $HTTP_CODE (custom domain may not be configured yet)" |
| 47 | + echo "::warning::Health check returned $HTTP_CODE" |
53 | 48 | fi |
54 | 49 |
|
55 | 50 | notify: |
|
62 | 57 | - uses: ./.github/actions/discord-notify |
63 | 58 | with: |
64 | 59 | title: "Registry Deploy — ${{ needs.deploy.result == 'success' && 'Deployed' || needs.deploy.result == 'cancelled' && 'Cancelled' || 'Failed' }}" |
65 | | - description: "Registry Lambda function updated" |
| 60 | + description: "Registry server updated" |
66 | 61 | status: ${{ needs.deploy.result == 'success' && 'success' || needs.deploy.result == 'cancelled' && 'warning' || 'failure' }} |
67 | 62 | fields: | |
68 | 63 | [ |
|
0 commit comments