Skip to content

chore(monorepo): update dependency @types/node to v22.19.3 #1159

chore(monorepo): update dependency @types/node to v22.19.3

chore(monorepo): update dependency @types/node to v22.19.3 #1159

name: 🚀 Deploy Preview
permissions:
contents: read
packages: write
actions: read
deployments: write
statuses: write
pull-requests: write
issues: write
on:
pull_request:
types: [opened, reopened, synchronize, edited]
workflow_dispatch:
inputs:
pr_number:
description: "Pull Request number to deploy"
required: true
type: string
concurrency:
group: ${{ github.workflow }}-pr-${{ github.event.number || github.event.inputs.pr_number }}
cancel-in-progress: true
jobs:
validate_secrets:
name: 🔒 Validate Secrets
uses: ./.github/workflows/validate-secrets.yml
secrets: inherit
with:
environment: preview
deploy_preview:
name: Build and Deploy Preview to Fly.io
runs-on: ubuntu-latest
outputs:
url: ${{ steps.deploy.outputs.url }}
status: ${{ job.status }}
environment:
name: fly-preview-${{ github.event.number || github.event.inputs.pr_number }}
url: ${{ steps.deploy.outputs.url }}
steps:
- name: Add deployment pending comment
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '🔄 Preview deployment started... Please wait while we deploy your changes!'
})
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed for flyctl release naming
# If triggered manually, ensure we checkout the PR
ref: ${{ github.event_name == 'workflow_dispatch' && format('refs/pull/{0}/merge', github.event.inputs.pr_number) || '' }}
- name: Prepare Repository Variables
id: vars
uses: ./.github/actions/prepare-repo-variables
with:
pr_number: ${{ github.event.inputs.pr_number || github.event.number }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# ─────────────────────────────────────────────────────────────
# Auto-generate tags & labels for the PR image
# ─────────────────────────────────────────────────────────────
- name: Extract image metadata
id: meta
uses: docker/[email protected]
with:
images: ${{ steps.vars.outputs.IMAGE_NAME_PREVIEW }}
tags: |
type=raw,pr-${{ steps.vars.outputs.PR_NUMBER }}
type=sha
labels: |
org.opencontainers.image.source=${{ github.repositoryUrl }}
org.opencontainers.image.revision=${{ github.sha }}
# 🏗 ---------- Docker build & push (single step) ----------
- name: 🐳 Build and Push Docker Image for Preview
timeout-minutes: 15
id: docker_build_push
uses: docker/build-push-action@v6
with:
context: .
file: ./packages/app/Dockerfile
push: true
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
github-token: ${{ secrets.GITHUB_TOKEN }}
provenance: false
sbom: false
#
# 1. Re-use layers from this PR.
# 2. Otherwise fall back to the “main” cache.
cache-from: |
type=gha,scope=preview-${{ steps.vars.outputs.PR_NUMBER }}
type=gha,scope=main
#
# Publish only to the PR-scoped GHA cache.
cache-to: |
type=gha,scope=preview-${{ steps.vars.outputs.PR_NUMBER }},mode=max
- name: 🚢 Deploy PR app to Fly.io
id: deploy
uses: superfly/[email protected]
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_APP_REVIEW }}
FLY_REGION: ams
FLY_ORG: personal
with:
config: ./packages/app/fly.review.yaml
name: ${{ steps.vars.outputs.FLY_APP_NAME }}
secrets: GITHUB_TOKEN=${{ secrets.OCTOKIT_RESUME_TOKEN }}
image: ${{ steps.vars.outputs.IMAGE_NAME_PREVIEW }}@${{ steps.docker_build_push.outputs.digest }}
- name: 🗑 Clean up old GHCR preview images for this PR
id: clean_old_images
if: success()
continue-on-error: true # Don’t fail the whole workflow if the tidy-up bombs
uses: actions/delete-package-versions@v5
with:
owner: ${{ github.repository_owner }}
package-type: container
package-name: suddenlygiovanni.dev/suddenlygiovanni.dev-preview
token: ${{ secrets.DELETE_DEPLOYMENT_PAT_TOKEN }} # PAT with `delete:packages`
# keep the most-recent two versions
min-versions-to-keep: 2
# regexes of versions that must NEVER be deleted
ignore-versions: |
^pr-${{ github.event.pull_request.number }}$
^pr-${{ github.event.pull_request.number }}-${{ github.sha }}$
delete-only-untagged-versions: false
delete-only-pre-release-versions: false
- name: Update PR with deployment status
if: always() && github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const result = "${{ job.status }}";
const url = "${{ steps.deploy.outputs.url }}";
const emoji = result === "success" ? "✅" : "❌";
let body = `${emoji} Preview deployment ${result.toLowerCase()}.\n\n`;
if (result === "success") {
body += `🌐 Preview URL: ${url}\n`;
body += `\nThis preview environment will be automatically cleaned up when the PR is closed.`;
} else {
body += `Deployment failed. Please check the [workflow logs](${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}) for more details.`;
}
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});