From 8f2eb40147995d28fa82272e5a0cb31fdbc7374c Mon Sep 17 00:00:00 2001 From: dasm Date: Tue, 29 Jul 2025 16:18:57 -0700 Subject: [PATCH 1/2] Use a composite action for docs pushes. --- .github/actions/push_docs/action.yml | 57 ++++++++++++++++++++++++++++ .github/workflows/commit.yml | 32 ++++------------ 2 files changed, 64 insertions(+), 25 deletions(-) create mode 100644 .github/actions/push_docs/action.yml diff --git a/.github/actions/push_docs/action.yml b/.github/actions/push_docs/action.yml new file mode 100644 index 00000000..faff1b16 --- /dev/null +++ b/.github/actions/push_docs/action.yml @@ -0,0 +1,57 @@ +name: 'Push Docs' +description: 'Build the docs in the current repository, and push it to another.' +inputs: + docs-repository: + description: The organization/name of the docs repository. + required: true + docs-repository-token: + description: A token that grants read/write access to the docs repository. + required: true + docs-path: + description: The path to the current set of docs (e.g. core vs analytics) within the docs repository. + required: true + version: + description: The version of the docs to push to. + required: true + dry-run: + description: If true, pushes to a new branch rather than the default branch. + required: false + default: false +runs: + using: composite + steps: + - name: Get commit + id: commit + run: echo "COMMIT=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" + shell: bash + - run: uv run nox -s docs + shell: bash + - run: rm -r public/.doctrees + shell: bash + - name: Checkout docs repository + uses: actions/checkout@v4 + with: + repository: ${{ inputs.docs-repository }} + token: ${{ inputs.docs-repository-token }} + path: docs-repo + - run: rm -r docs-repo/${{ inputs.docs-path }}/${{ inputs.version }} + shell: bash + - run: mv public docs-repo/${{ inputs.docs-path }}/${{ inputs.version }} + shell: bash + - name: update version information + working-directory: docs-repo + run: python update-versions.py ${{ inputs.docs-path }}/ + shell: bash + - name: commit to docs repo + working-directory: docs-repo + env: + COMMIT: ${{ steps.commit.outputs.COMMIT}} + run: | + git config user.name "docs-bot" + git config user.email "87283505+opendp-dev@users.noreply.github.com" + git config --global push.autoSetupRemote true + if [ ${{ inputs.dry-run }} ]; then git checkout -b dry-run/$COMMIT; fi + git add ${{ inputs.docs-path }} + git commit -m "[auto] Publish docs for ${{ inputs.version }} ($COMMIT)" + git push + shell: bash \ No newline at end of file diff --git a/.github/workflows/commit.yml b/.github/workflows/commit.yml index 4927db1b..3d3aef72 100644 --- a/.github/workflows/commit.yml +++ b/.github/workflows/commit.yml @@ -7,6 +7,7 @@ on: branches: - 'main' + env: # Force nox to produce colorful logs: FORCE_COLOR: "true" @@ -40,29 +41,10 @@ jobs: with: name: dist path: dist - - name: Get commit - id: commit - run: echo "COMMIT=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" - - run: uv run nox -s docs - - run: rm -r public/.doctrees - - name: Checkout docs repository - uses: actions/checkout@v4 + - name: Push docs + uses: ./.github/actions/push_docs with: - repository: 'opendp/tumult-docs' - token: ${{ secrets.DOCS_REPO_PAT}} - path: tumult-docs - - run: rm -r tumult-docs/docs/analytics/dev - - run: mv public tumult-docs/docs/analytics/dev - - name: update version information - working-directory: tumult-docs - run: python update-versions.py docs/analytics/ - - name: commit to docs repo - working-directory: tumult-docs - env: - COMMIT: ${{ steps.commit.outputs.COMMIT}} - run: | - git config user.name "docs-bot" - git config user.email "87283505+opendp-dev@users.noreply.github.com" - git add docs/analytics - git commit -m "[auto] Publish docs for dev ($COMMIT)" - git push + docs-repository: opendp/tumult-docs + docs-repository-token: ${{ secrets.DOCS_REPO_PAT }} + docs-path: docs/analytics + version: dev From b0e3f560c1b5b043cee13e5fe34fb610cf09f87c Mon Sep 17 00:00:00 2001 From: dasm Date: Wed, 30 Jul 2025 09:49:07 -0700 Subject: [PATCH 2/2] Add project to the commit message. --- .github/actions/push_docs/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/push_docs/action.yml b/.github/actions/push_docs/action.yml index faff1b16..bc991db1 100644 --- a/.github/actions/push_docs/action.yml +++ b/.github/actions/push_docs/action.yml @@ -52,6 +52,6 @@ runs: git config --global push.autoSetupRemote true if [ ${{ inputs.dry-run }} ]; then git checkout -b dry-run/$COMMIT; fi git add ${{ inputs.docs-path }} - git commit -m "[auto] Publish docs for ${{ inputs.version }} ($COMMIT)" + git commit -m "[auto] Publish docs for ${{ inputs.docs-path }} version ${{ inputs.version }} ($COMMIT)" git push shell: bash \ No newline at end of file