Skip to content

Commit 1f9881c

Browse files
committed
Revert "Remove trigger-azure-pipeline (#174)"
This reverts commit 7530616.
1 parent 7530616 commit 1f9881c

1 file changed

Lines changed: 87 additions & 0 deletions

File tree

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Trigger Azure Pipeline on PR Commit
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
types: [synchronize, opened]
8+
paths:
9+
- 'src/ByteSync.Common/**'
10+
- 'src/ByteSync.Functions/**'
11+
- 'src/ByteSync.ServerCommon/**'
12+
- 'tests/ByteSync.Common.Tests/**'
13+
- 'tests/ByteSync.Functions.IntegrationTests/**'
14+
- 'tests/ByteSync.Functions.UnitTests/**'
15+
- 'tests/ByteSync.ServerCommon.Tests/**'
16+
- 'tests/ByteSync.TestsCommon/**'
17+
18+
push:
19+
branches:
20+
- master
21+
paths:
22+
- 'src/ByteSync.Common/**'
23+
- 'src/ByteSync.Functions/**'
24+
- 'src/ByteSync.ServerCommon/**'
25+
- 'tests/ByteSync.Common.Tests/**'
26+
- 'tests/ByteSync.Functions.IntegrationTests/**'
27+
- 'tests/ByteSync.Functions.UnitTests/**'
28+
- 'tests/ByteSync.ServerCommon.Tests/**'
29+
- 'tests/ByteSync.TestsCommon/**'
30+
31+
workflow_dispatch:
32+
33+
jobs:
34+
trigger-azure-pipeline:
35+
if: ${{ github.actor == 'paul-fresquet' }} # allows only paul-fresquet
36+
runs-on: ubuntu-latest
37+
steps:
38+
39+
- name: Extract branch name
40+
shell: bash
41+
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_ENV
42+
id: extract_branch
43+
44+
- name: Get Pipeline ID by Name
45+
id: get-pipeline-id
46+
run: |
47+
response=$(curl -X GET -H "Authorization: Bearer ${{ secrets.AZURE_DEVOPS_TOKEN }}" \
48+
"${{ vars.AZURE_DEVOPS_PROJECT_URL }}/_apis/pipelines?api-version=6.0-preview.1")
49+
pipelineId=$(echo $response | jq -r '.value[] | select(.name=="${{ vars.AZURE_DEVOPS_PIPELINE }}") | .id')
50+
if [ -z "$pipelineId" ]; then
51+
echo "Error: Pipeline not found" >&2
52+
exit 1
53+
fi
54+
echo "pipelineId=$pipelineId" >> $GITHUB_ENV
55+
56+
- name: Trigger Azure Pipeline
57+
id: trigger-pipeline
58+
run: |
59+
response=$(curl -X POST -H "Authorization: Bearer ${{ secrets.AZURE_DEVOPS_TOKEN }}" \
60+
-H "Content-Type: application/json" \
61+
-d "{\"resources\": {}, \"variables\": {
62+
\"github-branch\": {
63+
\"value\": \"${branch}\"
64+
}
65+
}}" \
66+
"${{ vars.AZURE_DEVOPS_PROJECT_URL }}/_apis/pipelines/${{ env.pipelineId }}/runs?api-version=6.0-preview.1")
67+
echo "runId=$(echo $response | jq -r '.id')" >> $GITHUB_ENV
68+
echo "Response: $response"
69+
echo "runId=$(echo $response | jq -r '.id')" >> $GITHUB_ENV
70+
71+
- name: Wait for Pipeline to Complete
72+
id: wait-pipeline
73+
run: |
74+
status="inProgress"
75+
while [ "$status" == "inProgress" ]; do
76+
sleep 30
77+
response=$(curl -X GET -H "Authorization: Bearer ${{ secrets.AZURE_DEVOPS_TOKEN }}" \
78+
"${{ vars.AZURE_DEVOPS_PROJECT_URL }}/_apis/pipelines/${{ env.pipelineId }}/runs/${{ env.runId }}?api-version=6.0-preview.1")
79+
status=$(echo $response | jq -r '.state')
80+
done
81+
82+
result=$(echo $response | jq -r '.result')
83+
echo "result=$result" >> $GITHUB_ENV
84+
85+
- name: Check Pipeline Result
86+
if: env.result != 'succeeded'
87+
run: exit 1

0 commit comments

Comments
 (0)