forked from MicrosoftDocs/Agent-Skills
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub-azure-pipeline.yml
More file actions
193 lines (165 loc) · 7 KB
/
github-azure-pipeline.yml
File metadata and controls
193 lines (165 loc) · 7 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# Azure Pipeline: Sync Microsoft Learn Docs to Agent Skills
#
# This pipeline:
# 1. Checks out GitHub repo (contains products/, skills/)
# 2. Checks out ADO repo (contains src/, config/)
# 3. Runs docs2skills to crawl and classify docs
# 4. Pushes results back to GitHub repo
trigger: none
parameters:
- name: fullSync
displayName: 'Full Sync (use --full flag)'
type: boolean
default: false
- name: targetBranch
displayName: 'Target GitHub Branch'
type: string
default: 'main'
- name: docs2SkillsADOBranch
displayName: 'Docs2Skills ADO Branch'
type: string
default: 'main'
# schedules:
# - cron: "0 2 * * *" # Daily at 2:00 AM UTC
# displayName: Run every day
# branches:
# include:
# - main
# always: true
variables:
- group: Docs2Skills-Defaults
- name: pythonVersion
value: '3.12'
stages:
- stage: __default
jobs:
- job: Job
pool:
vmImage: ubuntu-latest
timeoutInMinutes: 240
steps:
# 1. Checkout GitHub repo (self - contains products/, skills/)
- task: Checkout@1
displayName: 'Checkout GitHub repo'
inputs:
repository: self
persistCredentials: true
# 2. Checkout ADO repo (source code)
- task: Checkout@1
displayName: 'Checkout ADO repo (code)'
inputs:
repository: git://Engineering/Learn.Docs2AgentSkills@refs/heads/${{ parameters.docs2SkillsADOBranch }}
# 3. Setup Python
- task: UsePythonVersion@0
displayName: 'Setup Python $(pythonVersion)'
inputs:
versionSpec: '$(pythonVersion)'
# 4. Install dependencies
- task: Bash@3
displayName: 'Install dependencies'
inputs:
targetType: inline
script: |
set -e
cd $(Build.SourcesDirectory)/Learn.Docs2AgentSkills
pip install --upgrade pip
pip install -r requirements.txt
# 5. Run docs2skills with Azure identity
- task: AzureCLI@2
displayName: 'Run docs2skills'
inputs:
azureSubscription: $(azureSubscription)
scriptType: bash
scriptLocation: inlineScript
inlineScript: |
set -e
# Define paths
ADO_REPO="$(Build.SourcesDirectory)/Learn.Docs2AgentSkills"
GITHUB_REPO="$(Build.SourcesDirectory)/$(basename $(Build.Repository.Uri) .git)"
PRODUCTS_DIR="$GITHUB_REPO/products"
SKILLS_DIR="$GITHUB_REPO/skills"
cd $ADO_REPO
echo "========================================"
echo "Starting docs sync"
echo "========================================"
echo "ADO repo (code): $ADO_REPO"
echo "GitHub repo (data): $GITHUB_REPO"
echo "Products dir: $PRODUCTS_DIR"
echo "Skills dir: $SKILLS_DIR"
echo "Azure OpenAI: $(azureOpenAIEndpoint)"
echo "Deployment: $(azureOpenAIDeployment)"
echo "Full Sync: ${{ parameters.fullSync }}"
echo "Target Branch: ${{ parameters.targetBranch }}"
echo "========================================"
FULL_FLAG=""
if [ "${{ parameters.fullSync }}" = "True" ]; then
FULL_FLAG="--full"
echo "Running with --full flag"
# check before delete
if [ -n "$PRODUCTS_DIR" ] && [ -d "$PRODUCTS_DIR" ]; then
rm -rf "$PRODUCTS_DIR"
mkdir -p "$PRODUCTS_DIR"
fi
if [ -n "$SKILLS_DIR" ] && [ -d "$SKILLS_DIR" ]; then
rm -rf "$SKILLS_DIR"
mkdir -p "$SKILLS_DIR"
fi
fi
echo "========================================"
echo "Processing Well-Architected Framework"
echo "========================================"
python -m src.docs2skills \
--config-type waf \
--products-dir $PRODUCTS_DIR \
--skills-dir $SKILLS_DIR
echo "========================================"
echo "Processing Cloud Adoption Framework"
echo "========================================"
python -m src.docs2skills \
--config-type caf \
--products-dir $PRODUCTS_DIR \
--skills-dir $SKILLS_DIR
echo "========================================"
echo "Processing Azure Architecture Center"
echo "========================================"
python -m src.docs2skills \
--config-type aac \
--products-dir $PRODUCTS_DIR \
--skills-dir $SKILLS_DIR
echo "========================================"
echo "Processing Azure Other Products"
echo "========================================"
python -m src.docs2skills \
--products-dir $PRODUCTS_DIR \
--skills-dir $SKILLS_DIR
echo "========================================"
echo "Sync completed"
echo "========================================"
env:
AZURE_OPENAI_ENDPOINT: $(azureOpenAIEndpoint)
AZURE_OPENAI_CHAT_DEPLOYMENT: $(azureOpenAIDeployment)
# 6. Push to GitHub repo
- task: Bash@3
displayName: 'Push to GitHub'
inputs:
targetType: inline
script: |
set -e
GITHUB_REPO=$(basename $(Build.Repository.Uri) .git)
cd $(Build.SourcesDirectory)/$GITHUB_REPO
git config user.email "[email protected]"
git config user.name "Docs2Skills Pipeline"
CHANGED_FILES=$(git status --porcelain products/ skills/ | wc -l)
if [ "$CHANGED_FILES" -gt 0 ]; then
echo "Changed files: $CHANGED_FILES"
git status --short products/ skills/
git add products/ skills/
TIMESTAMP=$(date +"%Y-%m-%d %H:%M")
git commit -m "$TIMESTAMP - Generate skills from docs (code: ADO/${{ parameters.docs2SkillsADOBranch }}, target: GitHub/${{ parameters.targetBranch }})"
TARGET_BRANCH="${{ parameters.targetBranch }}"
# Use refs/heads/ to ensure branch is created if it doesn't exist
git push origin HEAD:refs/heads/$TARGET_BRANCH
echo "Pushed changes to GitHub branch: $TARGET_BRANCH"
else
echo "No changes detected"
fi