feat: publish chofusai website #158
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
name: deploy to Cloudflare Pages | |
on: push | |
jobs: | |
build-and-deploy: | |
name: Build and Deploy to Cloudflare Pages | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
deployments: write | |
actions: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node.js and Install dependencies with yarn berry | |
uses: "./.github/actions/setup-node-yarn-berry" | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Restore cached Astro Assets | |
id: restore-astro-assets | |
uses: actions/cache/restore@v3 | |
with: | |
path: | | |
node_modules/.astro | |
key: ${{ runner.os }}-astro-assets-${{ hashFiles('node_modules/.astro/assets/**') }} | |
restore-keys: | | |
${{ runner.os }}-astro-assets- | |
- name: Build | |
run: yarn run build | |
env: | |
TWEET_API_URL: ${{ secrets.TWEET_API_URL }} | |
SHOW_DRAFT_POST: ${{ github.ref_name != 'main' && github.ref_name != 'beta' }} | |
- name: Cache Astro Assets | |
id: cache-astro-assets | |
uses: actions/cache/save@v3 | |
with: | |
path: | | |
node_modules/.astro | |
key: ${{ runner.os }}-astro-assets-${{ hashFiles('node_modules/.astro/assets/**') }} | |
- name: Clean up old Astro asset cache if newer cache created in current branch | |
uses: ./.github/actions/clean-old-cache | |
with: | |
cache-key-prefix: "${{ runner.os }}-astro-assets-" | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish to Cloudflare Pages | |
uses: cloudflare/pages-action@v1 | |
with: | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
projectName: ${{ vars.CLOUDFLARE_PAGES_PROJECT_NAME }} | |
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" |