flow-ipc-sync-doc-event #42
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: Flow-IPC sync-docs/releases pipeline | |
# See also flow_sync.yml. | |
on: | |
# An API request can trigger us; so Code (source) repo can invoke us after generating docs and checking those | |
# in to itself. | |
repository_dispatch: | |
types: [flow-ipc-sync-doc-event] | |
# To create the button that runs a workflow manually: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Branch or Tag name (e.g.: `main`, `vA.B.C`); can also be specified as API parameter.' | |
required: false | |
default: 'main' | |
jobs: | |
update-docs-releases: | |
runs-on: ubuntu-latest | |
env: | |
version: ${{ github.event.inputs.version || github.event.client_payload.version || 'main' }} | |
steps: | |
# Write access is required later, so at least 1 way to allow it is under Settings/Actions/General | |
# set "Workflow permissions" to "Read and write permissions" (may need similar org-wide change first). | |
- name: Checkout Pages repo (the destination) | |
uses: actions/checkout@v4 | |
with: | |
path: 'dst_repo' | |
sparse-checkout: | | |
doc/flow-ipc/versions | |
.github/scripts | |
README.md | |
- name: Checkout Code repo (the source) | |
uses: actions/checkout@v4 | |
with: | |
repository: 'Flow-IPC/ipc' | |
path: 'src_repo' | |
ref: ${{ env.version }} | |
sparse-checkout: 'doc/ipc_doc' | |
- name: Replace Pages (destination) docs with copy of Code (source) docs | |
run: | | |
# Replace Pages (destination) docs with copy of Code (source) docs. | |
cd dst_repo | |
DOC_DIR=doc/flow-ipc/versions | |
BRANCH=${{ env.version }} | |
rm -rf $DOC_DIR/$BRANCH | |
mkdir -p $DOC_DIR | |
cp -rv ../src_repo/doc/ipc_doc $DOC_DIR/$BRANCH | |
# These values informally recommended in: | |
# https://github.com/actions/checkout#push-a-commit-using-the-built-in-token | |
git config user.name github-actions | |
git config user.email [email protected] | |
git rm -r --cached $DOC_DIR/$BRANCH || echo "No [$DOC_DIR/$BRANCH] currently checked in; no problem." | |
git add $DOC_DIR/$BRANCH | |
- name: Update root page to link to those docs/release (if it is a new release) | |
run: | | |
# Replace Pages (destination) docs with copy of Code (source) docs. | |
cd dst_repo | |
.github/scripts/massage_root_page.pl ${{ env.version }} README.md Flow-IPC ipc | |
git add README.md # If no changes then this is successful no-op. | |
echo 'Having possibly modified README.md, here are the differences if any.' | |
echo '[[[ diff--' | |
git diff --cached README.md | |
echo '--diff ]]]' | |
- name: Check-in modifications (if any) to Pages (destination) repo | |
run: | | |
# Check-in modifications (if any) to Pages (destination) repo. | |
cd dst_repo | |
git commit -m 'Sync documentation from Code repo to Pages repo. Possibly update root-page links.' \ | |
|| { echo 'No changes: no problem.'; exit 0; } | |
git push origin main |