Skip to content

Commit

Permalink
[GitHub] Separate preview and production actions (#16931)
Browse files Browse the repository at this point in the history
* [GitHub] Separate preview and production actions

* Remove unnecessary 'if'

* Scope to production branches only

* remove prev workflow
  • Loading branch information
kodster28 authored Sep 18, 2024
1 parent d8a7ae5 commit 4075ce3
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
on: [push, workflow_dispatch]
on:
pull_request:
branches:
- production

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ !contains(github.ref, 'production')}}
cancel-in-progress: true

jobs:
publish:
runs-on: ubuntu-22.04
permissions:
contents: read
name: Publish to Cloudflare Pages
name: Publish to Cloudflare Pages (Preview)
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
Expand All @@ -31,13 +34,7 @@ jobs:
env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
- run: npm run build:worker && npx wrangler deploy -c ./wrangler-workers.toml
if: github.ref == 'refs/heads/production'
name: Deploy to Cloudflare Workers [production]
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
- run: npm run build:worker && npx wrangler versions upload -c ./wrangler-workers.toml
if: github.ref != 'refs/heads/production'
name: Deploy to Cloudflare Workers [preview]
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/publish-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
on:
pull_request:
branches:
- production
types:
- closed

jobs:
publish:
if: github.event.pull_request.merged == true
runs-on: ubuntu-22.04
permissions:
contents: read
name: Publish to Cloudflare Pages (Production)
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22.x
cache: npm
- run: npm ci
- uses: actions/cache/restore@v4
with:
path: |
node_modules/.astro/_astro
node_modules/.astro/assets
key: static
- run: npx astro build
env:
NODE_OPTIONS: --max-old-space-size=4096
- run: npx wrangler pages deploy --project-name cloudflare-docs dist
name: Deploy to Cloudflare Pages
env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
- uses: actions/cache/save@v4
if: always()
with:
path: |
node_modules/.astro/_astro
node_modules/.astro/assets
key: static

0 comments on commit 4075ce3

Please sign in to comment.