-
Notifications
You must be signed in to change notification settings - Fork 16
38 lines (33 loc) · 1.31 KB
/
trigger-azure-pipeline.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
name: Trigger Azure DevOps Pipeline
on:
push:
branches: [ main, develop ]
jobs:
trigger-azure-pipeline:
runs-on: ubuntu-latest
steps:
- name: Trigger Azure DevOps Pipeline
run: |
PAT="${{ secrets.AZURE_DEVOPS_PAT }}" # Azure DevOps Personal Access Token
ORG="sergiovelderrain" # Replace with your Azure DevOps org name
PROJECT="sergiovelderrain" # Replace with your project name
PIPELINE_ID="1" # Replace with your pipeline ID
API_VERSION="6.0-preview.1"
# Create base64 encoded auth header value
AUTH=$(echo -n ":$PAT" | base64)
# JSON body to specify branch or other resources (adjust as needed)
JSON_BODY='{
"resources": {
"repositories": {
"self": {
"refName": "refs/heads/'"${GITHUB_REF##*/}"'"
}
}
}
}'
# Trigger Azure DevOps pipeline run
curl -X POST \
-H "Authorization: Basic $AUTH" \
-H "Content-Type: application/json" \
-d "$JSON_BODY" \
"https://dev.azure.com/$ORG/$PROJECT/_apis/pipelines/$PIPELINE_ID/runs?api-version=$API_VERSION"