-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpreview.yml
87 lines (81 loc) · 2.95 KB
/
preview.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: preview [cloudflare]
on:
pull_request:
branches:
- main
jobs:
prepare:
runs-on: ubuntu-latest
permissions:
actions: read
checks: read
contents: read
deployments: write
issues: write
discussions: read
packages: read
pages: read
pull-requests: write
repository-projects: read
security-events: read
statuses: read
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
- uses: moonrepo/setup-toolchain@abc36a5d744a0b6dff6fd87201c49917c145deb9 # v0.3.1
with:
auto-install: true
- id: build
run: |
temp_file=$(mktemp)
moon --color --log info ci site:build | tee "$temp_file"
if grep -q "No targets to run based on touched files" "$temp_file"; then
echo "skip=true" >> $GITHUB_OUTPUT
else
echo "skip=false" >> $GITHUB_OUTPUT
fi
rm "$temp_file"
env:
ASTRO_STUDIO_APP_TOKEN: ${{ secrets.ASTRO_STUDIO_APP_TOKEN }}
# MOONBASE_SECRET_KEY: ${{ secrets.MOONBASE_SECRET_KEY }}
- uses: moonrepo/run-report-action@a92e881fd7c6bd680f64bfa1219ac7ddf3c3d009 # v1.6.1
if: ${{ steps.build.outputs.skip != 'true' }}
with:
access-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
if: ${{ steps.build.outputs.skip != 'true' }}
id: deployment
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { default: script } = await import('${{ github.workspace }}/.github/scripts/create-deployment.js')
await script({github, context, core})
- uses: cloudflare/wrangler-action@7c01cc48d88a1f83b4716e0557c168854a9dcdb8 # v3.4.1
if: ${{ steps.build.outputs.skip != 'true' }}
id: wrangler
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
wranglerVersion: "3.53.1"
workingDirectory: "apps/site"
packageManager: pnpm
command: pages deploy dist --project-name astrolicious
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
if: ${{ steps.build.outputs.skip != 'true' }}
env:
DEPLOYMENT_ID: ${{ steps.deployment.outputs.deployment-id }}
DEPLOYMENT_URL: ${{ steps.wrangler.outputs.deployment-url }}
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { default: script } = await import('${{ github.workspace }}/.github/scripts/update-deployment.js')
await script({github, context, core})
build:
name: Build
runs-on: ubuntu-latest
deploy:
needs: build
name: Deploy / Preview
runs-on: ubuntu-latest