-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipeline.yml
54 lines (46 loc) · 1.68 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
trigger:
- main
pool:
vmImage: 'windows-latest'
name: 'Build'
variables:
- group: GitHubSecrets # Variable group for GitHub credentials
jobs:
- job: MirrorRepo
displayName: 'Mirror Azure DevOps Repo to GitHub'
steps:
# Step 1: Install Git (if not already available)
- script: |
git --version
displayName: 'Check Git Version'
# Step 2: Configure Git User
- script: |
git config --global user.name "$(GITHUB_USERNAME)"
git config --global user.email "$(GITHUB_EMAIL)"
displayName: 'Configure Git User'
# Step 3: Add GitHub Remote if Not Exists
- script: |
git remote get-url mirror >nul 2>nul
if %ERRORLEVEL% NEQ 0 (
git remote add mirror https://$(GITHUB_USERNAME):$(GITHUB_PAT)@github.com/KentuckyDepartmentForPublicHealth/PHT.git
) else (
echo "Remote 'mirror' already exists"
)
env:
GITHUB_USERNAME: $(GITHUB_USERNAME)
GITHUB_PAT: $(GITHUB_PAT)
displayName: 'Add GitHub Remote'
# Step 4: Set GitHub Remote URL with Credentials
- script: |
git remote set-url mirror https://$(GITHUB_USERNAME):$(GITHUB_PAT)@github.com/KentuckyDepartmentForPublicHealth/PHT.git
env:
GITHUB_USERNAME: $(GITHUB_USERNAME)
GITHUB_PAT: $(GITHUB_PAT)
displayName: 'Set GitHub Remote URL'
# Step 5: Push Changes to GitHub
- script: |
git push mirror HEAD:main
env:
GITHUB_USERNAME: $(GITHUB_USERNAME)
GITHUB_PAT: $(GITHUB_PAT)
displayName: 'Mirror Repo to GitHub'