ci: extract Configure Site URL step into composite action#381
Closed
sakinaroufid wants to merge 1 commit intoUniversal-Commerce-Protocol:mainfrom
Closed
Conversation
Four jobs in docs.yml (build_and_verify_main, build_and_verify_release, deploy_main, deploy_release) duplicated the same nine-line shell block that queries the GitHub Pages API, falls back to a constructed URL, and exports SITE_URL and SPEC_URL to $GITHUB_ENV. Any change to the URL resolution logic required editing four places. Factor the block into a new composite action at .github/actions/configure-site-url, following the existing setup-build-env pattern. The action accepts the GitHub token as an input (defaulting to github.token) and writes the same two environment variables, so downstream steps are unchanged. Net change: 36 LOC of duplication removed, replaced with a single 25-line action plus four one-line 'uses' invocations. No runtime behavior change.
Author
|
Closing — opened prematurely. Will reopen when ready. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Four jobs in
.github/workflows/docs.yml=build_and_verify_main,build_and_verify_release,deploy_main, anddeploy_release& each contained an identical nine-line inline shell block that queries the GitHub Pages API, falls back to a constructed URL when the API returns nothing, normalises the trailing slash, and exportsSITE_URL/SPEC_URLto\$GITHUB_ENV. Any change to the URL-resolution logic (e.g. a new suffix, a fallback tweak, a token-scope change) required editing all four places in lockstep.This PR factors that block into a new composite action at
.github/actions/configure-site-url/action.yml, matching the pattern already established by.github/actions/setup-build-env/action.yml.Changes
.github/actions/configure-site-url/action.yml- composite action that wraps the existing logic. Takes an optionalgithub-tokeninput (defaulting togithub.token) and exportsSITE_URL+SPEC_URLto\$GITHUB_ENV, preserving the exact contract downstream steps rely on..github/workflows/docs.yml- each of the four duplicated blocks is replaced with- uses: ./.github/actions/configure-site-url.Net: 36 LOC of duplication removed, replaced with a single 25-line action plus four single-line invocations. No runtime behaviour change.
Test plan
lintjob passes (yamllint)build_and_verify_mainpasses - exercises the composite action and consumes\$SITE_URL/\$SPEC_URLinbuild_local.sh+check_links.py\$GITHUB_ENVvs. the previous inline block)Notes for reviewers
github.tokenas the default forgithub-token, which is functionally equivalent to the prior\${{ secrets.GITHUB_TOKEN }}- both resolve to the automatically-minted workflow token with the same scope. Kept it overridable so a caller could supply a broader token if needed../.github/actions/setup-build-envimmediately before the inlined block, so ordering is preserved.Configure Git Credentialsblocks, which are also duplicated but differ slightly in context (one job configures git for pushing togh-pages, others don't). Happy to extract those in a follow-up if desired.