Update Tests to support both Unix and Windows builds. #42
This file contains 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: Pull Request Build and Validation | |
on: | |
pull_request: | |
branches: | |
- main | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get Azure DevOps Access Token | |
id: getToken | |
uses: "./.github/actions/get-ado-token" | |
with: | |
client-id: ${{ secrets.AZURE_CLIENT_ID }} | |
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | |
organization: ${{ secrets.ADO_ORGANIZATION }} | |
- name: Trigger Azure DevOps Pipeline | |
id: trigger | |
run: | | |
response=$(curl -v -X POST \ | |
-H "Authorization: Bearer ${{ steps.getToken.outputs.token }}" \ | |
-H "Content-Type: application/json" \ | |
-d '{"resources": {"repositories": {"self": {"refName": "refs/heads/users/mbarbour/pipelineUpdate"}},"variables": {"ProjectBranch": {"value": "main"}}}}' \ | |
${{ secrets.AZDEVOPS_URL }}/_apis/pipelines/25676/runs?api-version=7.1) | |
echo $BRANCH_NAME | |
echo $response | |
echo "::set-output name=run_id::$(echo $response | jq -r .id)" | |
env: | |
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
# -d '{"resources": {"repositories": {"self": {"refName": "refs/heads/main"}}}}' \ | |
- name: Monitor Pipeline Run | |
run: | | |
run_id=${{ steps.trigger.outputs.run_id }} | |
status="inProgress" | |
while [ "$status" == "inProgress" ] || [ "$status" == "notStarted" ] || [ "$status" == "canceling" ] ; do | |
response=$(curl -X GET \ | |
-H "Authorization: Bearer ${{ steps.getToken.outputs.token }}" \ | |
${{ secrets.AZDEVOPS_URL }}/_apis/pipelines/25676/runs/$run_id?api-version=7.1) | |
status=$(echo $response | jq -r .state) | |
r1=$(echo $response | jq -r .result) | |
weblink=$(echo $response | jq -r ._links.web.href) | |
echo "Pipeline status: $status" | |
echo "Result response: $r1" | |
echo "WebLink: $weblink" | |
if [ "$status" == "completed" ]; then | |
result=$(echo $response | jq -r .result) | |
if [ "$result" == "succeeded" ]; then | |
echo "Pipeline succeeded" | |
exit 0 | |
else | |
echo "::error file={name},line={line},endLine={endLine},title={title}::Pipeline failed with result: $result" | |
echo "Pipeline failed with result: $result" | |
exit 1 | |
fi | |
fi | |
sleep 10 | |
done |