Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making actions work with new-ish GitHub pages #69

Open
mine-cetinkaya-rundel opened this issue Feb 12, 2023 · 5 comments
Open

Making actions work with new-ish GitHub pages #69

mine-cetinkaya-rundel opened this issue Feb 12, 2023 · 5 comments

Comments

@mine-cetinkaya-rundel
Copy link

I was having quite a bit of trouble using quarto-publish-example as a basis and following instructions from here when "Source: GitHub Pages [Beta]" is selected on my Pages settings.

image

Ultimately I was able to get things working with the following, using static.yml as a basis.

# Simple workflow for deploying static content to GitHub Pages
name: Publish Quarto page to GitHub Pages

on:
  # Runs on pushes targeting the default branch
  push:
    branches: ["main"]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
  contents: read
  pages: write
  id-token: write

# Allow one concurrent deployment
concurrency:
  group: "pages"
  cancel-in-progress: true

jobs:
  # Single deploy job since we're just deploying
  publish-site:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    container:
      image: ghcr.io/dukestatsci/r_gh_actions:latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Build site
        run: |
          quarto render
      
      - name: Setup Pages
        uses: actions/configure-pages@v3
      
      - name: Upload artifact
        uses: actions/upload-pages-artifact@v1
        with:
          path: '_site/'
      
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v1

I thought it might be helpful to leave this here but also to address the various GitHub pages options in the instructions at https://github.com/quarto-dev/quarto-actions/tree/main/publish#github-pages? I am still not 100% clear on the organization of this repo so I don't have a concrete PR to make but I'm happy to try if this is actually something missing (as opposed to something I missed even though it's addressed).

@cscheid
Copy link
Contributor

cscheid commented Feb 13, 2023

What kind of trouble were you having? Maybe the GitHub UI changed after we wrote these instructions? I agree this repo could use a documentation overhaul, and we've struggled in the past with how to balance the many different ways in which people use GHA.

@cderv
Copy link
Collaborator

cderv commented Feb 14, 2023

One question to clarify something for me: Is quarto publish command not something desired or not working in this project ?

Our action is way to wrap quarto publish command line so that project is rendered and deployed to a branch following the repo setting. The idea is to leverage the Github's way to publish thanks to a branch or folder (https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-from-a-branch). We document this approach in this repo.

In static.yml, this is explicitly using Github action probably following https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-with-a-custom-github-actions-workflow. This is a bit different and would only use quarto-actions/render as the publish is manually configured and done. We don't document this approach yet (Install quarto, install deps, render project using quarto action, use other external actions to deploy).

Also static.yml is using a container and I wonder if our actions are working in this context or not. This could be the blocker you encountered maybe.

@rgaiacs
Copy link

rgaiacs commented Jun 21, 2023

Hi, my Git project uses git-crypt and this is making quarto publish gh-pages to fail with the follow message

git-crypt: Error: Unable to open key file - have you unlocked/initialized this repository yet?
error: external filter '"git-crypt" smudge' failed 1
error: external filter '"git-crypt" smudge' failed
fatal: helm/charts/gesis/files/minesweeper/secrets/herorat.py: smudge filter git-crypt failed
ERROR: Error executing 'git': No such file or directory (os error 2)

Stack trace:
    at execProcess (file:///opt/quarto/bin/quarto.js:5273:15)
    at withWorktree (file:///opt/quarto/bin/quarto.js:95549:11)
    at eventLoopTick (ext:core/01_core.js:181:11)
    at async Object.publish4 [as publish] (file:///opt/quarto/bin/quarto.js:95388:5)
    at async publishSite (file:///opt/quarto/bin/quarto.js:96063:38)
    at async publish5 (file:///opt/quarto/bin/quarto.js:96277:61)
    at async doPublish (file:///opt/quarto/bin/quarto.js:96237:13)
    at async publishAction (file:///opt/quarto/bin/quarto.js:96248:9)
    at async Command.fn (file:///opt/quarto/bin/quarto.js:96225:9)
    at async Command.execute (file:///opt/quarto/bin/quarto.js:8105:13)

I believe that use upload-pages-artifact will resolve the issue.

@cderv
Copy link
Collaborator

cderv commented Jun 21, 2023

@rgaiacs Are you able to publish to Github pages usually with git-crypt ? What quarto publish is doing is running git to check the rendered website to gh-pages before pushing the pages online. I wonder what would required for this to work for your locally.

@jolars
Copy link

jolars commented May 31, 2024

I came up with something similar, also based on the same static.yaml template, that seems to work well for me too. Here is a minimal boilerplate:

on:
  workflow_dispatch:
  push:
    branches: [main]

name: Quarto Publish

permissions:
  contents: read
  pages: write
  id-token: write

concurrency:
  group: "pages"
  cancel-in-progress: false

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Check out repository
        uses: actions/checkout@v4

      - name: Setup Pages
        uses: actions/configure-pages@v5

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

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

      - name: Upload artifact
        uses: actions/upload-pages-artifact@v3
  deploy:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    needs: build
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants