From 9862016e4bcaa4c99e72091013d48f786e0f3783 Mon Sep 17 00:00:00 2001 From: AkanshuS Date: Wed, 4 Dec 2024 20:26:41 -0500 Subject: [PATCH 1/6] Create publish.yml I have used the documentation (https://quarto.org/docs/publishing/quarto-pub.html#github-action) to create the publish.yml file. Will need to get the Quarto Pub credentials. I'm unable to test on my local machine using this command as I keep getting this error for quarto publish quarto-pub: ERROR: MissingEnvVarsError: The following variables were defined in the example file but are not present in the environment: SECRET_KEY, BASE_URL, DB_USER, DB_PASSWORD, DB_HOST, DB_PORT, DB_NAME, RESEND_API_KEY Make sure to add them to your env file. If you expect any of these variables to be empty, you can set the allowEmptyValues option to true. Stack trace: SECRET_KEY, BASE_URL, DB_USER, DB_PASSWORD, DB_HOST, DB_PORT, DB_NAME, RESEND_API_KEY Make sure to add them to your env file. If you expect any of these variables to be empty, you can set the allowEmptyValues option to true. at assertSafe (file:///opt/quarto/bin/quarto.js:26186:15) at load3 (file:///opt/quarto/bin/quarto.js:26147:9) at eventLoopTick (ext:core/01_core.js:153:7) at async dotenvQuartoProfile (file:///opt/quarto/bin/quarto.js:26288:18) at async initializeProfileConfig (file:///opt/quarto/bin/quarto.js:26353:46) at async projectContext (file:///opt/quarto/bin/quarto.js:73559:29) at async createPublishOptions (file:///opt/quarto/bin/quarto.js:109627:21) at async publishAction (file:///opt/quarto/bin/quarto.js:109548:28) at async Command.actionHandler (file:///opt/quarto/bin/quarto.js:109543:9) at async Command.execute (file:///opt/quarto/bin/quarto.js:8017:13) --- .github/workflows/publish.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..c49ccd5 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,28 @@ +on: + workflow_dispatch: + push: + branches: main + + name: Quarto Publish + + jobs: + build-deploy: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Quarto + uses: quarto-dev/quarto-actions/setup@v2 + + - name: Render and Publish + uses: quarto-dev/quarto-actions/publish@v2 + with: + target: quarto-pub + QUARTO_PUB_AUTH_TOKEN: ${{ secrets.QUARTO_PUB_AUTH_TOKEN }} + +# - name: Traditionally Render & Publish +# run: | +# quarto publish +# quarto render index.qmd --output-dir . --output README.md --to gfm +# unlink index.html # Can skip this step if we add/commit/push only the README rather than all changed files From 396c2f9d4c570a932ab14a64ab50c35f75ad2752 Mon Sep 17 00:00:00 2001 From: AkanshuS Date: Mon, 9 Dec 2024 16:44:04 -0500 Subject: [PATCH 2/6] Update publish.yml 1.) Removed quarto-pub 2.) Added setup and env variables like in test.yml 3.) Added Render --- .github/workflows/publish.yml | 91 +++++++++++++++++++++++++---------- 1 file changed, 66 insertions(+), 25 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c49ccd5..3bebb17 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,28 +1,69 @@ +name: Publish-and-Render + on: - workflow_dispatch: - push: - branches: main + push: + pull_request: + branches: [main] + workflow_dispatch: + +jobs: + test: + strategy: + fail-fast: false + matrix: + python-version: ["3.12"] + poetry-version: [latest] + os: [ubuntu-latest] + + runs-on: ${{ matrix.os }} + + services: + postgres: + image: postgres:latest + env: + POSTGRES_DB: test_db + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + steps: + - uses: actions/checkout@v4 - name: Quarto Publish - - jobs: - build-deploy: - runs-on: ubuntu-latest - steps: - - name: Check out repository - uses: actions/checkout@v4 - - - name: Set up Quarto - uses: quarto-dev/quarto-actions/setup@v2 - - - name: Render and Publish - uses: quarto-dev/quarto-actions/publish@v2 - with: - target: quarto-pub - QUARTO_PUB_AUTH_TOKEN: ${{ secrets.QUARTO_PUB_AUTH_TOKEN }} + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Set env variables for quarto + run: | + echo "DB_USER=postgres" >> $GITHUB_ENV + echo "DB_PASSWORD=postgres" >> $GITHUB_ENV + echo "DB_HOST=127.0.0.1" >> $GITHUB_ENV + echo "DB_PORT=5432" >> $GITHUB_ENV + echo "DB_NAME=test_db" >> $GITHUB_ENV + echo "SECRET_KEY=$(openssl rand -base64 32)" >> $GITHUB_ENV + echo "BASE_URL=http://localhost:8000" >> $GITHUB_ENV -# - name: Traditionally Render & Publish -# run: | -# quarto publish -# quarto render index.qmd --output-dir . --output README.md --to gfm -# unlink index.html # Can skip this step if we add/commit/push only the README rather than all changed files + - name: Verify environment variables for quarto + run: | + echo "Checking if required environment variables are set..." + [ -n "$DB_USER" ] && \ + [ -n "$DB_PASSWORD" ] && \ + [ -n "$DB_HOST" ] && \ + [ -n "$DB_PORT" ] && \ + [ -n "$DB_NAME" ] && \ + [ -n "$SECRET_KEY" ] + + - name: Set up Quarto + uses: quarto-dev/quarto-actions/setup@v2 + + - name: Publish + uses: quarto-dev/quarto-actions/publish@v2 + + - name: Render + uses: quarto-dev/quarto-actions/render@v2 From d92231d96d820dae203e084950668b8a28685412 Mon Sep 17 00:00:00 2001 From: AkanshuS Date: Thu, 9 Jan 2025 01:32:39 -0500 Subject: [PATCH 3/6] Update publish.yml with RESEND_API_KEY value --- .github/workflows/publish.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3bebb17..78ea663 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -48,6 +48,7 @@ jobs: echo "DB_NAME=test_db" >> $GITHUB_ENV echo "SECRET_KEY=$(openssl rand -base64 32)" >> $GITHUB_ENV echo "BASE_URL=http://localhost:8000" >> $GITHUB_ENV + echo "RESEND_API_KEY"=$(openssl rand -base64 32)" >> $GITHUB_ENV - name: Verify environment variables for quarto run: | @@ -57,7 +58,8 @@ jobs: [ -n "$DB_HOST" ] && \ [ -n "$DB_PORT" ] && \ [ -n "$DB_NAME" ] && \ - [ -n "$SECRET_KEY" ] + [ -n "$SECRET_KEY" ] && \ + [ -n "$RESEND_API_KEY" ] - name: Set up Quarto uses: quarto-dev/quarto-actions/setup@v2 From 164373b4462133079073ec0ce06263256a4d9de5 Mon Sep 17 00:00:00 2001 From: AkanshuS Date: Thu, 9 Jan 2025 01:34:38 -0500 Subject: [PATCH 4/6] Update publish.yml remove extra quotation mark --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 78ea663..9d4b0af 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -48,7 +48,7 @@ jobs: echo "DB_NAME=test_db" >> $GITHUB_ENV echo "SECRET_KEY=$(openssl rand -base64 32)" >> $GITHUB_ENV echo "BASE_URL=http://localhost:8000" >> $GITHUB_ENV - echo "RESEND_API_KEY"=$(openssl rand -base64 32)" >> $GITHUB_ENV + echo "RESEND_API_KEY=$(openssl rand -base64 32)" >> $GITHUB_ENV - name: Verify environment variables for quarto run: | From 754be5b57459eefe45fa273c8482f2677701649c Mon Sep 17 00:00:00 2001 From: AkanshuS Date: Thu, 9 Jan 2025 01:56:29 -0500 Subject: [PATCH 5/6] Update publish.yml Claude --- .github/workflows/publish.yml | 110 ++++++++++++++++------------------ 1 file changed, 51 insertions(+), 59 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9d4b0af..cdcccde 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,71 +1,63 @@ -name: Publish-and-Render +name: Update Documentation on: push: - pull_request: - branches: [main] + branches: [ main ] + paths: + - 'index.qmd' + - '.github/workflows/update-docs.yml' workflow_dispatch: jobs: - test: - strategy: - fail-fast: false - matrix: - python-version: ["3.12"] - poetry-version: [latest] - os: [ubuntu-latest] - - runs-on: ${{ matrix.os }} - - services: - postgres: - image: postgres:latest - env: - POSTGRES_DB: test_db - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - ports: - - 5432:5432 - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - + update-docs: + runs-on: ubuntu-latest + permissions: + contents: write steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-python@v5 + - name: Check out repository + uses: actions/checkout@v4 with: - python-version: ${{ matrix.python-version }} - - - name: Set env variables for quarto - run: | - echo "DB_USER=postgres" >> $GITHUB_ENV - echo "DB_PASSWORD=postgres" >> $GITHUB_ENV - echo "DB_HOST=127.0.0.1" >> $GITHUB_ENV - echo "DB_PORT=5432" >> $GITHUB_ENV - echo "DB_NAME=test_db" >> $GITHUB_ENV - echo "SECRET_KEY=$(openssl rand -base64 32)" >> $GITHUB_ENV - echo "BASE_URL=http://localhost:8000" >> $GITHUB_ENV - echo "RESEND_API_KEY=$(openssl rand -base64 32)" >> $GITHUB_ENV - - - name: Verify environment variables for quarto - run: | - echo "Checking if required environment variables are set..." - [ -n "$DB_USER" ] && \ - [ -n "$DB_PASSWORD" ] && \ - [ -n "$DB_HOST" ] && \ - [ -n "$DB_PORT" ] && \ - [ -n "$DB_NAME" ] && \ - [ -n "$SECRET_KEY" ] && \ - [ -n "$RESEND_API_KEY" ] + fetch-depth: 0 - name: Set up Quarto uses: quarto-dev/quarto-actions/setup@v2 - - name: Publish - uses: quarto-dev/quarto-actions/publish@v2 - - - name: Render - uses: quarto-dev/quarto-actions/render@v2 + - name: Render Documentation + run: | + # Publish Quarto documentation + quarto publish --no-prompt --no-browser + + # Render README in GitHub Flavored Markdown + quarto render index.qmd --output-dir . --output README.md --to gfm + + # Remove index.html if it exists + rm -f index.html + + - name: Commit and Push Changes + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + + # Stage only specific files + git add README.md + + # Only commit if there are changes + git diff --staged --quiet || git commit -m "docs: Update README.md via automated workflow" + + # Push changes + git push + + # Optional step for generating additional documentation files + - name: Generate Additional Documentation + if: false # Disabled by default - enable when needed + run: | + # Example: Generate .txt version + quarto render index.qmd --output-dir . --output rules.txt --to plain + + # Example: Generate .cursorrules version + quarto render index.qmd --output-dir . --output rules.cursorrules --to plain + + # Commit and push additional files + git add rules.txt rules.cursorrules + git diff --staged --quiet || git commit -m "docs: Update additional documentation files" + git push From 6a4eaad5c7fb6197aaf4dd4b1a7cf763f7db22c1 Mon Sep 17 00:00:00 2001 From: "Christopher C. Smith" Date: Sun, 16 Feb 2025 21:01:56 -0500 Subject: [PATCH 6/6] Publish workflow with Github app bypass --- .github/workflows/publish.yml | 73 ++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index cdcccde..da382a7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,27 +1,52 @@ -name: Update Documentation +name: Publish Documentation on: push: - branches: [ main ] - paths: - - 'index.qmd' - - '.github/workflows/update-docs.yml' - workflow_dispatch: + branches: main jobs: - update-docs: + publish-documentation: runs-on: ubuntu-latest permissions: + id-token: write contents: write steps: + - name: Generate token for version incrementer app + id: create_token + uses: tibdex/github-app-token@v2 + with: + app_id: ${{ secrets.APP_ID }} + private_key: ${{ secrets.PRIVATE_KEY }} + - name: Check out repository uses: actions/checkout@v4 with: fetch-depth: 0 + ref: ${{ github.sha }} + token: ${{ steps.create_token.outputs.token }} + + - name: Install uv + uses: astral-sh/setup-uv@v5 + + - name: "Set up Python" + uses: actions/setup-python@v5 + with: + python-version-file: "pyproject.toml" + + - name: Install dependencies + run: uv sync - name: Set up Quarto uses: quarto-dev/quarto-actions/setup@v2 + - name: Configure Git + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + + - name: Render and Publish + run: uv run quarto publish gh-pages --no-prompt --no-browser + - name: Render Documentation run: | # Publish Quarto documentation @@ -33,31 +58,9 @@ jobs: # Remove index.html if it exists rm -f index.html - - name: Commit and Push Changes - run: | - git config --local user.email "github-actions[bot]@users.noreply.github.com" - git config --local user.name "github-actions[bot]" - - # Stage only specific files - git add README.md - - # Only commit if there are changes - git diff --staged --quiet || git commit -m "docs: Update README.md via automated workflow" - - # Push changes - git push - - # Optional step for generating additional documentation files - - name: Generate Additional Documentation - if: false # Disabled by default - enable when needed - run: | - # Example: Generate .txt version - quarto render index.qmd --output-dir . --output rules.txt --to plain - - # Example: Generate .cursorrules version - quarto render index.qmd --output-dir . --output rules.cursorrules --to plain - - # Commit and push additional files - git add rules.txt rules.cursorrules - git diff --staged --quiet || git commit -m "docs: Update additional documentation files" - git push + - name: Commit version change + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "Update README" + branch: ${{ github.ref_name }} + file_pattern: "README.md"