Update generated docs #1822
This file contains hidden or 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: Update generated docs | |
| on: | |
| schedule: | |
| - cron: "0 */2 * * *" | |
| workflow_dispatch: | |
| inputs: | |
| targets: | |
| description: "Generated-doc targets to run" | |
| type: string | |
| default: "all" | |
| dry_run: | |
| description: "List selected target commands without generating or publishing changes" | |
| type: boolean | |
| default: false | |
| permissions: | |
| actions: write | |
| checks: read | |
| contents: write | |
| pull-requests: write | |
| concurrency: | |
| group: update-generated-docs | |
| cancel-in-progress: false | |
| # The canton-network-cf-docs runner contract provides Nix through a shared store and daemon. | |
| jobs: | |
| select-targets: | |
| runs-on: canton-network-cf-docs | |
| outputs: | |
| target_matrix: ${{ steps.select-targets.outputs.target_matrix }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| with: | |
| persist-credentials: false | |
| - name: Select generated-doc targets | |
| id: select-targets | |
| env: | |
| GENERATED_DOCS_TARGETS: ${{ inputs.targets || 'all' }} | |
| run: | | |
| target_matrix="$(SKIP_NPM_INSTALL=1 nix-shell --run 'python3 scripts/update_generated_reference_prs.py --targets $GENERATED_DOCS_TARGETS --print-target-matrix-json')" | |
| echo "target_matrix=$target_matrix" >> "$GITHUB_OUTPUT" | |
| update-generated-docs: | |
| needs: select-targets | |
| name: Update ${{ matrix.target }} | |
| runs-on: canton-network-cf-docs | |
| environment: cf-docs-generated-docs-merger | |
| strategy: | |
| fail-fast: false | |
| max-parallel: 1 | |
| matrix: ${{ fromJSON(needs.select-targets.outputs.target_matrix) }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| with: | |
| persist-credentials: false | |
| - name: Approve and verify project environment | |
| run: SKIP_NPM_INSTALL=1 direnv allow . && SKIP_NPM_INSTALL=1 direnv exec . true | |
| - name: Install npm dependencies | |
| run: SKIP_NPM_INSTALL=1 nix-shell --run 'npm ci' | |
| - name: Set up Daml tooling | |
| if: ${{ matrix.requires_daml_tooling }} | |
| run: | | |
| SKIP_NPM_INSTALL=1 nix-shell --run 'bash scripts/install_daml_tooling.sh' | |
| echo "$HOME/.dpm/bin" >> "$GITHUB_PATH" | |
| echo "$HOME/.daml/bin" >> "$GITHUB_PATH" | |
| - name: Verify generated-doc dependencies | |
| env: | |
| GENERATED_DOCS_DEPENDENCY_ARGS: ${{ matrix.requires_daml_tooling && '--require-daml' || '' }} | |
| run: SKIP_NPM_INSTALL=1 nix-shell --run "python3 scripts/check_generated_docs_dependencies.py $GENERATED_DOCS_DEPENDENCY_ARGS" | |
| - name: Check generated-docs merger app configuration | |
| id: merger-app | |
| env: | |
| GENERATED_DOCS_MERGER_APP_ID: ${{ secrets.GENERATED_DOCS_MERGER_APP_ID }} | |
| GENERATED_DOCS_MERGER_PRIVATE_KEY: ${{ secrets.GENERATED_DOCS_MERGER_PRIVATE_KEY }} | |
| run: | | |
| if [[ -n "$GENERATED_DOCS_MERGER_APP_ID" && -n "$GENERATED_DOCS_MERGER_PRIVATE_KEY" ]]; then | |
| echo "configured=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "configured=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Generate generated-docs merger app token | |
| id: merger-token | |
| if: ${{ steps.merger-app.outputs.configured == 'true' }} | |
| uses: actions/create-github-app-token@v2 | |
| with: | |
| app-id: ${{ secrets.GENERATED_DOCS_MERGER_APP_ID }} | |
| private-key: ${{ secrets.GENERATED_DOCS_MERGER_PRIVATE_KEY }} | |
| - name: Configure generated-docs PR authentication | |
| env: | |
| GH_TOKEN: ${{ steps.merger-token.outputs.token || github.token }} | |
| run: SKIP_NPM_INSTALL=1 nix-shell --run 'gh auth setup-git' | |
| - name: Generate update pull requests | |
| env: | |
| GH_TOKEN: ${{ steps.merger-token.outputs.token || github.token }} | |
| GITHUB_TOKEN: ${{ steps.merger-token.outputs.token || github.token }} | |
| GENERATED_DOCS_MERGER_TOKEN: ${{ steps.merger-token.outputs.token }} | |
| GENERATED_DOCS_WORKFLOW_TOKEN: ${{ github.token }} | |
| run: | | |
| args=(python3 scripts/update_generated_reference_prs.py --targets "${{ matrix.target }}") | |
| if [[ "${{ inputs.dry_run || false }}" == "true" ]]; then | |
| args+=(--dry-run) | |
| fi | |
| printf -v generated_docs_command '%q ' "${args[@]}" | |
| SKIP_NPM_INSTALL=1 nix-shell --run "$generated_docs_command" |