-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
arranged Github workflows on deployment
- Loading branch information
1 parent
7dc6a2e
commit 75d9073
Showing
3 changed files
with
55 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,68 @@ | ||
on: [push] | ||
name: Deployment to Cloudflare Pages | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
publish: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
deployments: write | ||
name: Publish to Cloudflare Pages | ||
statuses: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
# Run a build step here if your project requires | ||
|
||
- name: Set up node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version-file: 'package.json' | ||
- name: Set up yarn with corepack | ||
run: | | ||
corepack enable yarn | ||
yarn --version | ||
- name: Get yarn cache dir | ||
id: yarn_cache | ||
run: echo "STORE_PATH=$(yarn store path)" >> $GITHUB_OUTPUT | ||
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 --frozen-lockfile | ||
- name: Build project | ||
run: yarn build | ||
- name: Publish to Cloudflare Pages | ||
id: cloudflare_pages_deploy | ||
uses: cloudflare/pages-action@v1 | ||
with: | ||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
accountId: YOUR_ACCOUNT_ID | ||
projectName: YOUR_PROJECT_NAME | ||
directory: YOUR_BUILD_OUTPUT_DIRECTORY | ||
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 }} | ||
# 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 | ||
# branch: main | ||
# Optional: Change the working directory | ||
workingDirectory: my-site | ||
# workingDirectory: my-site | ||
# Optional: Change the Wrangler version, allows you to point to a specific version or a tag such as `beta` | ||
wranglerVersion: '3' | ||
# 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 }}", | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
"cSpell.words": [ | ||
"astro", | ||
"astrojs", | ||
"corepack", | ||
"datetime", | ||
"fontsource", | ||
"iconify", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,5 +58,8 @@ | |
"remark-math": "^6.0.0", | ||
"wrangler": "^3.29.0" | ||
}, | ||
"packageManager": "[email protected]" | ||
"packageManager": "[email protected]", | ||
"engines": { | ||
"node": ">=18.16.0" | ||
} | ||
} |