The best way to control Claude Code, Codex and more from any computer or phone
| 1 | name: Publish blogpost |
| 2 | |
| 3 | # Publishes blog posts from main to production without shipping unreleased |
| 4 | # docs: checks out the latest release tag, overlays the blog folders from |
| 5 | # main, and deploys the website to alchemy.run. |
| 6 | on: |
| 7 | workflow_dispatch: |
| 8 | inputs: |
| 9 | tag: |
| 10 | description: "Release tag to deploy (defaults to the latest v* tag reachable from main)" |
| 11 | type: string |
| 12 | required: false |
| 13 | paths: |
| 14 | description: "Space-separated folders copied from main onto the release" |
| 15 | type: string |
| 16 | default: "website/src/content/docs/blog website/public/blog" |
| 17 | |
| 18 | # Same group as production deploys in website.yml, so the two never race. |
| 19 | concurrency: |
| 20 | group: deploy-website-prod |
| 21 | cancel-in-progress: false |
| 22 | |
| 23 | jobs: |
| 24 | publish: |
| 25 | name: Publish blogpost |
| 26 | runs-on: blacksmith-4vcpu-ubuntu-2404 |
| 27 | permissions: |
| 28 | contents: read |
| 29 | steps: |
| 30 | - name: Checkout repository |
| 31 | uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 32 | with: |
| 33 | ref: main |
| 34 | fetch-depth: 0 |
| 35 | |
| 36 | - name: Resolve release tag |
| 37 | id: release |
| 38 | env: |
| 39 | TAG: ${{ inputs.tag }} |
| 40 | run: | |
| 41 | set -euo pipefail |
| 42 | tag="${TAG:-$(git describe --tags --abbrev=0 --match 'v*' origin/main)}" |
| 43 | sha="$(git rev-parse "$tag^{commit}")" |
| 44 | echo "Deploying $tag ($sha) with blog content from main $(git rev-parse --short origin/main)" |
| 45 | echo "tag=$tag" >> "$GITHUB_OUTPUT" |
| 46 | echo "sha=$sha" >> "$GITHUB_OUTPUT" |
| 47 | |
| 48 | - name: Check out release and overlay blog from main |
| 49 | env: |
| 50 | TAG: ${{ steps.release.outputs.tag }} |
| 51 | PATHS: ${{ inputs.paths }} |
| 52 | run: | |
| 53 | set -euo pipefail |
| 54 | git checkout --detach "$TAG" |
| 55 | # `git restore` mirrors main exactly, so posts deleted on main are |
| 56 | # deleted here too. |
| 57 | read -ra paths <<< "$PATHS" |
| 58 | git restore --source=origin/main --staged --worktree -- "${paths[@]}" |
| 59 | git status --short |
| 60 | |
| 61 | - name: Checkout distilled |
| 62 | run: git submodule update --init --depth=1 --checkout -- submodules/distilled |
| 63 | |
| 64 | - name: Setup pnpm, Node.js, Bun and install dependencies |
| 65 | uses: pnpm/setup@703c52620218391530e48b9e8870d5c0082e1b9b # v2.1.0 |
| 66 | with: |
| 67 | cache: true |
| 68 | install: true |
| 69 | require-lockfile: true |
| 70 | |
| 71 | - name: Deploy |
| 72 | working-directory: website |
| 73 | run: bun alchemy deploy --stage prod --yes |
| 74 | env: |
| 75 | CLOUDFLARE_API_TOKEN: ${{ secrets.PROD_CLOUDFLARE_API_TOKEN }} |
| 76 | CLOUDFLARE_ACCOUNT_ID: ${{ secrets.PROD_CLOUDFLARE_ACCOUNT_ID }} |
| 77 | BUILD_SHA: ${{ steps.release.outputs.sha }} |