quarto-dev / quarto-actions

GNU General Public License v2.0
228 stars 53 forks source link

Cloudflare Publish Action #70

Closed arnold-c closed 1 year ago

arnold-c commented 1 year ago

Thanks for putting these actions together.

I'm wondering if it would be possible to create a GitHub Action to publish to Cloudflare? Currently I'm using the GA to publish to GitHub Pages, and then using CloudFlare Pages to deploy from the gh-pages branch. This works, but effectively duplicates the output (CloudFlare and GitHub Pages). Just using the render action didn't seem to trigger any changes to the gh-pages branch, therefore does not result in any downstream changes to the published document as there's nothing for CloudFlare to update.

If I'm missing an obvious solution, please let me know!

arnold-c commented 1 year ago

Please feel free to close this if you feel this is a sufficient fix for the moment, but I've found a workaround using Cloudflare Direct Upload and posting here in case it's useful for others.

You need to adapt this action, so the final action looks something like below.


on:
  workflow_dispatch:
  push:
    branches: main

name: Quarto Publish

jobs:
  build-deploy:
    runs-on: ubuntu-latest
    permissions:
      contents: write
      deployments: write # needed for Cloudflare
    steps:
      - name: Check out repository
        uses: actions/checkout@v3

      - name: Set up Quarto
        uses: quarto-dev/quarto-actions/setup@v2
        with:
          tinytex: true

      - name: Render Quarto Project
        uses: quarto-dev/quarto-actions/render@v2

      - name: Publish
        uses: cloudflare/pages-action@1
        with:
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
          projectName: #cloudflare-project-id
          directory: '_book'
          gitHubToken: ${{ secrets.GITHUB_TOKEN }}
cderv commented 1 year ago

For context, our quarto-actions/publish is based on quarto publish command, and this command does not support Cloudfare. This would be a feature request to https://github.com/quarto-dev/quarto-cli

Your solution is definitely what we would recommend for any other service than the one supported by quarto publish. We do not mention Cloudfare explicitly in our doc (https://quarto.org/docs/publishing/other.html) but the idea is there: Render then publish.

I added an example based on yours. Thanks !