Skip to content

Commit

Permalink
Improvements in PR trigger
Browse files Browse the repository at this point in the history
- Add git checkout step with parameters.
- Update ref name to trigger PR.
  • Loading branch information
josesimoes committed Dec 18, 2024
1 parent 9d98d3a commit 94189bb
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ parameters:
default: TestStream

steps:
- checkout: self
clean: true
fetchDepth: 1

- script: |
# Validate required environment variables
for var in AZURE_DEVOPS_PAT BUILD_SOURCEBRANCH; do
Expand All @@ -31,6 +35,18 @@ steps:
poolName="${{ parameters.AZURE_POOL_NAME }}"
branch="${BUILD_SOURCEBRANCH}"
# Fetch the PR details from GitHub to get the title
# Extract the PR ID from the branch name
prId=$(echo "$BUILD_SOURCEBRANCH" | sed -n 's|refs/pull/\([0-9]\+\)/merge|\1|p')
auth=$(echo -n ":$GITHUB_TOKEN" | base64)
auth="basic $auth"
prUrl="https://api.github.com/repos/$env:Build_Repository_Name/pulls/$env:System_PullRequest_PullRequestNumber"
prResponse=$(curl -s -H "Authorization: $auth" -X GET "$prUrl")
prTitle=$(echo "$prResponse" | jq -r '.title')
echo "PR Title: $prTitle"
# Encode the PAT
patEncoded=$(echo -n ":${AZURE_DEVOPS_PAT}" | base64)
Expand Down Expand Up @@ -65,7 +81,7 @@ steps:
echo "Unique userCapabilities names: \"$capabilityNames\""
# Prepare the parameters
parametersJson=$(jq -n --arg appComponents "- $capabilityNames" '{templateParameters: {appComponents: $appComponents}}')
parametersJson=$(jq -n --arg appComponents "- $capabilityNames" --arg prTitle "$prTitle" '{templateParameters: {appComponents: $appComponents, prTitle: $prTitle}}')
echo "Parameters: \"$parametersJson\""
echo "Branch for PR: \"$branch\""
Expand Down

0 comments on commit 94189bb

Please sign in to comment.