Skip to content

Commit

Permalink
arranged Github workflows on deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
brklntmhwk committed Mar 1, 2024
1 parent 7dc6a2e commit 75d9073
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 14 deletions.
63 changes: 50 additions & 13 deletions .github/workflows/deploy.yml
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 }}",
});
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"cSpell.words": [
"astro",
"astrojs",
"corepack",
"datetime",
"fontsource",
"iconify",
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,8 @@
"remark-math": "^6.0.0",
"wrangler": "^3.29.0"
},
"packageManager": "[email protected]"
"packageManager": "[email protected]",
"engines": {
"node": ">=18.16.0"
}
}

0 comments on commit 75d9073

Please sign in to comment.