chore(lambda): update deps #47
This file contains hidden or 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: Deploy Staging (PR Preview) | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| TF_VAR_env: staging | |
| TF_VAR_zone_id: ${{ secrets.LIVE_ZONE_ID }} | |
| TF_VAR_root_domain: lhowsam.com | |
| TF_VAR_sub_domain: nowplaying.lhowsam.com | |
| TF_VAR_private_key: ${{ secrets.STAGING_PRIVATE_KEY }} | |
| TF_VAR_certificate_body: ${{ secrets.STAGING_CERTIFICATE_BODY }} | |
| TF_VAR_certificate_chain: ${{ secrets.STAGING_CERTIFICATE_CHAIN }} | |
| TF_VAR_deployed_by: ${{ github.actor }} | |
| TF_VAR_git_sha: ${{ github.sha }} | |
| TF_VAR_api_key: ${{ secrets.STAGING_API_KEY }} | |
| TF_VAR_discord_webhook_url: ${{ secrets.DISCORD_ALERTS_WEBHOOK_URL }} | |
| permissions: write-all | |
| jobs: | |
| deploy: | |
| name: Deploy to Staging | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ github.head_ref }} | |
| - name: Ensure rebased with main | |
| run: ./scripts/ensure-rebased.sh | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version-file: ".bun-version" | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Get pre-release version | |
| id: version | |
| run: | | |
| BASE_VERSION=$(jq -r .version package.json) | |
| PR_NUMBER=${{ github.event.pull_request.number }} | |
| SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7) | |
| PRERELEASE_VERSION="${BASE_VERSION}-pr.${PR_NUMBER}.${SHORT_SHA}" | |
| echo "version=${PRERELEASE_VERSION}" >> $GITHUB_OUTPUT | |
| echo "Pre-release version: ${PRERELEASE_VERSION}" | |
| - name: Deploy | |
| uses: ./.github/actions/deploy | |
| with: | |
| environment: ${{ env.TF_VAR_env }} | |
| aws-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| op-service-account-token: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} | |
| env: | |
| VERSION: ${{ steps.version.outputs.version }} | |
| - name: Comment on PR | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const version = '${{ steps.version.outputs.version }}'; | |
| const marker = '<!-- staging-deployment-comment -->'; | |
| const body = `${marker}\n## 🚀 Staging Deployment\n\n- **Version**: \`${version}\`\n- **URL**: https://nowplaying-staging.lhowsam.com\n- **Health**: https://nowplaying-staging.lhowsam.com/api/health\n- **Version API**: https://nowplaying-staging.lhowsam.com/api/version`; | |
| // Find existing comment | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| }); | |
| const existingComment = comments.find(comment => comment.body.includes(marker)); | |
| if (existingComment) { | |
| // Update existing comment | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: existingComment.id, | |
| body: body | |
| }); | |
| } else { | |
| // Create new comment | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: body | |
| }); | |
| } |