-
Notifications
You must be signed in to change notification settings - Fork 684
Add AzDO pipeline to bump decoupled deps and update API docs after publish #5661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
d073e94
Add AzDO pipeline to bump decoupled local dependencies after publish
iclanton f934b71
Fix GitHub PR step to show API error responses on failure
iclanton e9dabf8
Use service connection credentials from git config for GitHub API calls
iclanton f206d7d
Extract push + GitHub PR steps into a reusable template
iclanton c384780
Address PR review: sanitize inputs, protect credentials, add security…
iclanton 0ac60c3
Rename to npm-post-publish, publish api artifact, add API docs update…
iclanton 86170f5
Rename to npm-post-publish, add api artifact, add API docs update sta…
iclanton 1e5760c
Extract api artifact publishing to separate branch
iclanton b7045fa
fixup! Rename to npm-post-publish, add api artifact, add API docs upd…
iclanton 8d8bac6
fixup! Rename to npm-post-publish, add api artifact, add API docs upd…
iclanton 8c803ef
fixup! Rename to npm-post-publish, add api artifact, add API docs upd…
iclanton 63137c0
fixup! Rename to npm-post-publish, add api artifact, add API docs upd…
iclanton a33d3ce
fixup! Rename to npm-post-publish, add api artifact, add API docs upd…
iclanton 1652350
fixup! Rename to npm-post-publish, add api artifact, add API docs upd…
iclanton 10dade8
fixup! Rename to npm-post-publish, add api artifact, add API docs upd…
iclanton 2797344
fixup! Rename to npm-post-publish, add api artifact, add API docs upd…
iclanton 0ac30e7
fixup! Rename to npm-post-publish, add api artifact, add API docs upd…
iclanton 728b415
fixup! Rename to npm-post-publish, add api artifact, add API docs upd…
iclanton 59b9867
fixup! Rename to npm-post-publish, add api artifact, add API docs upd…
iclanton 8963a0e
Only install to repo-toolbox.
iclanton 7bbe316
fixup! Rename to npm-post-publish, add api artifact, add API docs upd…
iclanton d5645af
fixup! Rename to npm-post-publish, add api artifact, add API docs upd…
iclanton a204ddd
fixup! Rename to npm-post-publish, add api artifact, add API docs upd…
iclanton b4be874
fixup! Rename to npm-post-publish, add api artifact, add API docs upd…
iclanton 4b5069d
fixup! Rename to npm-post-publish, add api artifact, add API docs upd…
iclanton ba040aa
fixup! Rename to npm-post-publish, add api artifact, add API docs upd…
iclanton d3bb564
fixup! Rename to npm-post-publish, add api artifact, add API docs upd…
iclanton f62258a
TEMP: download api artifact from latest npmPublish for testing
iclanton a4467e5
Use api-documenter-docusaurus-plugin.
iclanton 43b9ba8
fixup! Use api-documenter-docusaurus-plugin.
iclanton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| parameters: | ||
| - name: delayMinutes | ||
| displayName: 'Minutes to wait for packages to propagate before running' | ||
| type: number | ||
| default: 5 | ||
|
|
||
| variables: | ||
| - name: FORCE_COLOR | ||
| value: 1 | ||
| - name: BranchName | ||
| value: 'automated/bump-decoupled-deps' | ||
| - name: CommitMessage | ||
| value: 'chore: bump decoupled local dependencies' | ||
|
|
||
| resources: | ||
| pipelines: | ||
| - pipeline: npmPublish | ||
| source: 'rushstack NPM Publish' | ||
| trigger: | ||
| branches: | ||
| include: | ||
| - main | ||
| - pipeline: npmPublishRush | ||
| source: 'rushstack NPM Publish (rush)' | ||
| trigger: | ||
| branches: | ||
| include: | ||
| - main | ||
| repositories: | ||
| - repository: 1esPipelines | ||
| type: git | ||
| name: 1ESPipelineTemplates/1ESPipelineTemplates | ||
| ref: refs/tags/release | ||
|
|
||
| extends: | ||
| template: v1/1ES.Official.PipelineTemplate.yml@1esPipelines | ||
| parameters: | ||
| pool: | ||
| name: Azure-Pipelines-1ESPT-ExDShared | ||
| os: windows | ||
| stages: | ||
| - stage: | ||
| jobs: | ||
| - job: | ||
| pool: | ||
| name: publish-rushstack | ||
| os: linux | ||
| steps: | ||
| - checkout: self | ||
| persistCredentials: true | ||
|
|
||
| - bash: | | ||
| echo "Waiting ${{ parameters.delayMinutes }} minute(s) for packages to propagate to npm..." | ||
| sleep $(( ${{ parameters.delayMinutes }} * 60 )) | ||
| displayName: 'Wait for packages to propagate' | ||
|
|
||
| - template: /common/config/azure-pipelines/templates/install-node.yaml@self | ||
|
|
||
| - script: 'git config --local user.email rushbot@users.noreply.github.com' | ||
| displayName: 'git config email' | ||
|
|
||
| - script: 'git config --local user.name Rushbot' | ||
| displayName: 'git config name' | ||
|
|
||
| - script: 'node common/scripts/install-run-rush.js install' | ||
| displayName: 'Rush Install' | ||
|
|
||
| - script: 'node common/scripts/install-run-rush.js build --to repo-toolbox --verbose' | ||
| displayName: 'Rush Build (repo-toolbox)' | ||
|
|
||
| - script: 'node repo-scripts/repo-toolbox/lib-commonjs/start.js bump-decoupled-local-dependencies' | ||
| displayName: 'Bump decoupled local dependencies' | ||
|
|
||
| - script: 'node common/scripts/install-run-rush.js update' | ||
| displayName: 'Rush Update' | ||
|
|
||
| - bash: | | ||
| set -e | ||
|
|
||
| if git diff --quiet; then | ||
| echo "No changes detected. Skipping commit and PR." | ||
| echo "##vso[task.setvariable variable=HasChanges]false" | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "##vso[task.setvariable variable=HasChanges]true" | ||
|
|
||
| git checkout -B $(BranchName) | ||
| git add --all | ||
| git commit -m "$(CommitMessage)" | ||
| displayName: 'Commit dependency changes' | ||
|
|
||
| - bash: | | ||
| set -e | ||
|
|
||
| node common/scripts/install-run-rush.js change \ | ||
| --bulk \ | ||
| --bump-type none \ | ||
| --commit-message "chore: generate change files for decoupled dependency bump" | ||
| displayName: 'Generate change files' | ||
| condition: and(succeeded(), eq(variables.HasChanges, 'true')) | ||
|
|
||
| - template: /common/config/azure-pipelines/templates/push-and-create-github-pr.yaml@self | ||
| parameters: | ||
| BranchName: $(BranchName) | ||
| PrTitle: $(CommitMessage) | ||
| PrDescription: 'Automated PR to bump decoupled local dependencies to the latest published versions.' |
86 changes: 86 additions & 0 deletions
86
common/config/azure-pipelines/templates/push-and-create-github-pr.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| parameters: | ||
| - name: BranchName | ||
| type: string | ||
| - name: PrTitle | ||
| type: string | ||
| - name: PrDescription | ||
| type: string | ||
| default: '' | ||
| - name: TargetBranch | ||
| type: string | ||
| default: 'main' | ||
| - name: HasChangesVariableName | ||
| type: string | ||
| default: 'HasChanges' | ||
|
|
||
| steps: | ||
| - bash: | | ||
| set -e | ||
| git push origin ${{ parameters.BranchName }} --force | ||
| displayName: 'Push branch' | ||
| condition: and(succeeded(), eq(variables['${{ parameters.HasChangesVariableName }}'], 'true')) | ||
|
|
||
| - bash: | | ||
|
iclanton marked this conversation as resolved.
|
||
| set -e | ||
|
|
||
| # Derive owner/repo from the git remote | ||
| REPO_SLUG=$(git remote get-url origin | sed -E 's#.*github\.com[:/](.+/[^.]+)(\.git)?$#\1#') | ||
| echo "Repository: ${REPO_SLUG}" | ||
|
|
||
| # Extract the authorization header that AzDO configured via persistCredentials | ||
| AUTH_HEADER=$(git config --get-regexp 'http\..*\.extraheader' | head -1 | sed 's/^[^ ]* //') | ||
| if [ -z "$AUTH_HEADER" ]; then | ||
| echo "##[error]Could not extract authorization header from git config. Ensure persistCredentials is enabled on the checkout step." | ||
| exit 1 | ||
| fi | ||
|
|
||
| PR_TITLE="${{ parameters.PrTitle }}" | ||
| PR_BODY="${{ parameters.PrDescription }}" | ||
| API_BASE="https://api.github.com/repos/${REPO_SLUG}" | ||
|
|
||
| # Helper to call the GitHub API and fail with a visible error | ||
| github_api() { | ||
| local RESPONSE HTTP_CODE | ||
| RESPONSE=$(curl -s -w "\n%{http_code}" "$@") | ||
| HTTP_CODE=$(echo "$RESPONSE" | tail -n1) | ||
| BODY=$(echo "$RESPONSE" | sed '$d') | ||
|
|
||
| if [[ "$HTTP_CODE" -ge 200 && "$HTTP_CODE" -lt 300 ]]; then | ||
| echo "$BODY" | ||
| else | ||
| echo "::error::GitHub API returned HTTP ${HTTP_CODE}:" >&2 | ||
| echo "$BODY" >&2 | ||
| return 1 | ||
| fi | ||
| } | ||
|
|
||
| # Check if a PR already exists for this branch | ||
| OWNER=$(echo "${REPO_SLUG}" | cut -d/ -f1) | ||
| EXISTING_PR=$(github_api \ | ||
| -H "$AUTH_HEADER" \ | ||
| -H "Accept: application/vnd.github+json" \ | ||
| "${API_BASE}/pulls?head=${OWNER}:${{ parameters.BranchName }}&state=open" \ | ||
| | jq '.[0].number // empty') | ||
|
iclanton marked this conversation as resolved.
|
||
|
|
||
| if [ -n "$EXISTING_PR" ]; then | ||
| echo "Updating existing PR #${EXISTING_PR}" | ||
| github_api -X PATCH \ | ||
| -H "$AUTH_HEADER" \ | ||
| -H "Accept: application/vnd.github+json" \ | ||
| "${API_BASE}/pulls/${EXISTING_PR}" \ | ||
| -d "$(jq -n --arg body "$PR_BODY" '{body: $body}')" | ||
| else | ||
| echo "Creating new PR" | ||
| github_api -X POST \ | ||
| -H "$AUTH_HEADER" \ | ||
|
iclanton marked this conversation as resolved.
Outdated
|
||
| -H "Accept: application/vnd.github+json" \ | ||
| "${API_BASE}/pulls" \ | ||
| -d "$(jq -n \ | ||
| --arg title "$PR_TITLE" \ | ||
|
iclanton marked this conversation as resolved.
|
||
| --arg body "$PR_BODY" \ | ||
| --arg head "${{ parameters.BranchName }}" \ | ||
| --arg base "${{ parameters.TargetBranch }}" \ | ||
| '{title: $title, body: $body, head: $head, base: $base}')" | ||
| fi | ||
| displayName: 'Create or update GitHub PR' | ||
| condition: and(succeeded(), eq(variables['${{ parameters.HasChangesVariableName }}'], 'true')) | ||
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.
Uh oh!
There was an error while loading. Please reload this page.