Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(.github): Document and explain CI override directives (#10318)
## Description Updates inline comments in GitHub actions files to explain CI override directives (`#endo-branch`, `#getting-started-branch`, etc.) and adds references to them in the PR template to reduce our dependence upon oral tradition. Also, although out of scope for this PR and probably not needed, we might consider a future change to pull out a helper for consumption of such directives: <details><summary>.github/**/*.yml</summary> ```patch - name: Get the appropriate dapp branch id: get-branch - uses: actions/github-script@v7 + uses: ./.github/actions/read-pr-directive with: - result-encoding: string - script: | - let branch = 'main'; - if (context.payload.pull_request) { - const { body } = context.payload.pull_request; - const regex = /^\#getting-started-branch:\s+(\S+)/m; - const result = regex.exec(body); - if (result) { - branch = result[1]; - } - } - console.log('getting-started dapp branch: ' + branch); - return branch; + tag: '#getting-started-branch' + default-value: main ``` </details> <details><summary>.github/actions/read-pr-directive</summary> ```yaml name: Read PR Directive description: 'Read the value of a `#`-prefixed directive from a PR description' inputs: tag: description: 'The directive tag to read (must start with `#`)' required: true default-value: description: 'The value to return in the absence of any overriding directive' required: true outputs: result: description: >- The value of the last overriding directive, or the default value if the context is not a pull request or there is no such directive value: ${{ steps.script.outputs.result }} runs: using: composite steps: - id: script uses: actions/github-script@v7 env: TAG: ${{ inputs.tag }} DEFAULT_VALUE: ${{ inputs.default-value }} with: result-encoding: string script: |- const q = JSON.stringify; const { TAG, DEFAULT_VALUE } = process.env; if (!TAG.startsWith('#')) { throw Error(`malformed directive tag ${q(TAG)}`); } if (!context.payload.pull_request) return DEFAULT_VALUE; const { body } = context.payload.pull_request; const directives = body.matchAll(/^(\#[\w-]+):\s+(\S+)/gm); const selections = directives.filter(m => m[1] === TAG).map(m => m[2]); const selection = selections.pop(); for (const ignored of selections) { console.warn(`ignoring ${q(`${TAG}: ${ignored}`)}`); } console.log(`${TAG}: ${selection}`); return selection || DEFAULT_VALUE; ``` </details> ### Security Considerations n/a ### Scaling Considerations n/a ### Documentation Considerations :ballot_box_with_check: ### Testing Considerations n/a ### Upgrade Considerations n/a
- Loading branch information