Skip to content

feat: setup auto-publish and deploy to CF and npm #4

feat: setup auto-publish and deploy to CF and npm

feat: setup auto-publish and deploy to CF and npm #4

Workflow file for this run

# .github/workflows/preview.yml
name: Preview deploy all Workers and CLIs
on:
pull_request:
branches:
- main
types:
- opened
- reopened
- synchronize
env:
WORKSPACES: create-db create-pg create-postgres
# these must be defined in your GitHub “Environments” for this workflow
CREATE_DB_WORKER_URL: ${{ env.CREATE_DB_WORKER_URL }}

Check failure on line 16 in .github/workflows/preview.yml

View workflow run for this annotation

GitHub Actions / Preview deploy all Workers and CLIs

Invalid workflow file

The workflow is not valid. .github/workflows/preview.yml (Line: 16, Col: 25): Unrecognized named-value: 'env'. Located at position 1 within expression: env.CREATE_DB_WORKER_URL .github/workflows/preview.yml (Line: 17, Col: 24): Unrecognized named-value: 'env'. Located at position 1 within expression: env.CLAIM_DB_WORKER_URL
CLAIM_DB_WORKER_URL: ${{ env.CLAIM_DB_WORKER_URL }}
jobs:
preview:
name: 🚧 Preview release (PR #${{ github.event.number }})
runs-on: ubuntu-latest
steps:
- name: 🛎️ Checkout full history
uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: true
- name: 🤐 Disable Husky
run: echo "HUSKY=0" >> $GITHUB_ENV
- name: 📦 Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: 🔧 Install dependencies
run: pnpm install
- name: ❌ Disable pnpm git-checks
run: pnpm config set git-checks false
- name: 📄 Copy README to child CLIs
run: |
for pkg in create-pg create-postgres; do
cp create-db/README.md "$pkg/README.md"
done
- name: 🔖 Create unique preview tag
run: |
echo "PRE_TAG=pr${{ github.event.number }}-${{ github.event.pull_request.head.ref }}-${{ github.run_id }}" >> $GITHUB_ENV
# -- CF preview deploy is disabled; we’ll use env.CREATE_DB_WORKER_URL / CLAIM_DB_WORKER_URL instead
# - name: ☁️ Deploy create-db-worker (preview)
# uses: cloudflare/wrangler-action@v3
# with: ...
# - name: ☁️ Deploy claim-db-worker (preview)
# uses: cloudflare/wrangler-action@v3
# with: ...
- name: 🔑 Configure npm auth
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.CREATE_DB_TOKEN_NPM }}" > ~/.npmrc
- name: 🚀 Bump & publish CLI previews
env:
CREATE_DB_WORKER_URL: ${{ env.CREATE_DB_WORKER_URL }}
CLAIM_DB_WORKER_URL: ${{ env.CLAIM_DB_WORKER_URL }}
run: |
for pkg in $WORKSPACES; do
cd "$pkg"
npm version prerelease \
--preid "$PRE_TAG" \
--no-git-tag-version
pnpm publish --access public --tag pr${{ github.event.number }}
cd - >/dev/null
done
- name: 💬 Post preview-testing instructions
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const tag = process.env.PRE_TAG;
const dbUrl = process.env.CREATE_DB_WORKER_URL;
const clUrl = process.env.CLAIM_DB_WORKER_URL;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: `
✅ **Preview CLIs are live!**
Test locally under tag \`${tag}\`:
\`\`\`bash
npx create-db@${tag}
npx create-pg@${tag}
npx create-postgres@${tag}
\`\`\`
**Worker URLs**
• Create-DB: ${dbUrl}
• Claim-DB: ${clUrl}`
});
- name: 🧹 Cleanup npm auth
run: rm -f ~/.npmrc