Skip to content

Commit ad94ece

Browse files
kodster28elithrar
authored andcommitted
[GitHub] Separate preview and production actions (#16931)
* [GitHub] Separate preview and production actions * Remove unnecessary 'if' * Scope to production branches only * remove prev workflow
1 parent e77358a commit ad94ece

File tree

2 files changed

+48
-9
lines changed

2 files changed

+48
-9
lines changed

.github/workflows/publish.yml renamed to .github/workflows/publish-preview.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
on: [push, workflow_dispatch]
1+
on:
2+
pull_request:
3+
branches:
4+
- production
25

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

710
jobs:
811
publish:
912
runs-on: ubuntu-22.04
1013
permissions:
1114
contents: read
12-
name: Publish to Cloudflare Pages
15+
name: Publish to Cloudflare Pages (Preview)
1316
steps:
1417
- uses: actions/checkout@v4
1518
- uses: actions/setup-node@v4
@@ -31,13 +34,7 @@ jobs:
3134
env:
3235
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
3336
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
34-
- run: npm run build:worker && npx wrangler deploy -c ./wrangler-workers.toml
35-
if: github.ref == 'refs/heads/production'
36-
name: Deploy to Cloudflare Workers [production]
37-
env:
38-
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
3937
- run: npm run build:worker && npx wrangler versions upload -c ./wrangler-workers.toml
40-
if: github.ref != 'refs/heads/production'
4138
name: Deploy to Cloudflare Workers [preview]
4239
env:
4340
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
on:
2+
pull_request:
3+
branches:
4+
- production
5+
types:
6+
- closed
7+
8+
jobs:
9+
publish:
10+
if: github.event.pull_request.merged == true
11+
runs-on: ubuntu-22.04
12+
permissions:
13+
contents: read
14+
name: Publish to Cloudflare Pages (Production)
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-node@v4
18+
with:
19+
node-version: 22.x
20+
cache: npm
21+
- run: npm ci
22+
- uses: actions/cache/restore@v4
23+
with:
24+
path: |
25+
node_modules/.astro/_astro
26+
node_modules/.astro/assets
27+
key: static
28+
- run: npx astro build
29+
env:
30+
NODE_OPTIONS: --max-old-space-size=4096
31+
- run: npx wrangler pages deploy --project-name cloudflare-docs dist
32+
name: Deploy to Cloudflare Pages
33+
env:
34+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
35+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
36+
- uses: actions/cache/save@v4
37+
if: always()
38+
with:
39+
path: |
40+
node_modules/.astro/_astro
41+
node_modules/.astro/assets
42+
key: static

0 commit comments

Comments
 (0)