-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (75 loc) · 2.71 KB
/
deploy.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
name: Deployment to Cloudflare Pages
on:
push:
branches:
- main
env:
YARN_HOME: /home/runner/.local/share/yarn
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
statuses: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up node
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: yarn
- name: Configure Yarn path
run: echo "${{ env.YARN_HOME }}" >> $GITHUB_PATH
- name: Set up yarn with corepack
run: |
corepack enable
corepack prepare [email protected] --activate
yarn --version
# - name: Get yarn store path
# id: yarn_cache
# run: echo "STORE_PATH=$(yarn cache dir)" >> $GITHUB_OUTPUT
# - name: Set up yarn store
# uses: actions/cache@v4
# with:
# path: ${{ steps.yarn_cache.outputs.STORE_PATH }}
# key: ${{ runner.os }}-astro-${{ hashFiles('**/yarn-lock.yaml') }}
# restore-keys: ${{ runner.os }}-astro-
- name: Install dependencies
run: yarn install --immutable --immutable-cache --check-cache --inline-builds
- name: Build project
run: yarn run build
- name: Generate search index
run: npx pagefind --site dist
- name: Publish to Cloudflare Pages
id: cloudflare_pages_deploy
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: my-astro-blog
directory: dist
# Optional: Enable this if you want to have GitHub Deployments triggered
# gitHubToken: ${{ secrets.GITHUB_TOKEN }}
# Optional: Switch what branch you are publishing to.
# By default this will be the branch which triggered this workflow
# branch: main
# Optional: Change the working directory
# workingDirectory: my-site
# Optional: Change the Wrangler version, allows you to point to a specific version or a tag such as `beta`
# wranglerVersion: '3'
- name: Add publish URL
uses: actions/github-script@v6
with:
script: |
const sha = context.payload.pull_request?.head.sha ?? context.sha;
await github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
context: 'Cloudflare Pages',
description: 'Cloudflare Pages deployment',
state: 'success',
sha,
target_url: "${{ steps.cloudflare_pages_deploy.outputs.url }}",
});