Skip to content

release/v0.0.0-test #20

release/v0.0.0-test

release/v0.0.0-test #20

Workflow file for this run

name: Deployment
on:
push:
branches:
- main
pull_request:
branches:
- release/*
types:
- opened
- reopened
- synchronize
- closed
concurrency:
group: deploy-${{ github.ref }}
cancel-in-progress: false
env:
NODE_VERSION: '24.11.1'
PNPM_VERSION: '10.23.0'
STAGE: ${{ github.event_name == 'pull_request' && format('preview-{0}', github.event.number) || (github.ref == 'refs/heads/main' && 'production' || github.ref_name) }}
jobs:
deploy:
if: ${{ github.event.action != 'closed' }}
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
run_install: false
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Deploy
run: pnpm alchemy deploy --stage ${{ env.STAGE }}
env:
HOSTNAME: ${{ vars.HOSTNAME }}
ALCHEMY_SECRET: ${{ secrets.ALCHEMY_SECRET }}
ALCHEMY_STATE_TOKEN: ${{ secrets.ALCHEMY_STATE_TOKEN }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_EMAIL: ${{ secrets.CLOUDFLARE_EMAIL }}
PULL_REQUEST: ${{ github.event.number }}
GITHUB_SHA: ${{ github.sha }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
cleanup:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && github.event.action == 'closed' }}
permissions:
id-token: write
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
run_install: false
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Safety Check
run: |-
if [ "${{ env.STAGE }}" = "production" ]; then
echo "ERROR: Cannot destroy production environment in cleanup job"
exit 1
fi
- name: Destroy Preview Environment
run: pnpm alchemy destroy --stage ${{ env.STAGE }}
env:
HOSTNAME: ${{ vars.HOSTNAME }}
ALCHEMY_SECRET: ${{ secrets.ALCHEMY_SECRET }}
ALCHEMY_STATE_TOKEN: ${{ secrets.ALCHEMY_STATE_TOKEN }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_EMAIL: ${{ secrets.CLOUDFLARE_EMAIL }}
PULL_REQUEST: ${{ github.event.number }}