-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathazure-pipelines.yml
More file actions
68 lines (54 loc) · 1.92 KB
/
azure-pipelines.yml
File metadata and controls
68 lines (54 loc) · 1.92 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
# Azure DevOps Pipeline for GitHub Sync
# This pipeline automatically pushes changes from Azure DevOps main branch to GitHub
trigger:
branches:
include:
- main
pool:
vmImage: 'ubuntu-latest'
variables:
- group: GitHub-Integration # Variable group containing GitHubPAT
- name: githubRepository
value: 'NotMyself/new-windows-dev-pc'
- name: targetBranch
value: 'main'
steps:
- checkout: self
persistCredentials: true
clean: true
# GitHubRelease task removed - using direct git commands with PAT instead
- script: |
echo "Configuring git for push to GitHub..."
git config --global user.email "pipeline@notmyself.dev"
git config --global user.name "Azure DevOps Pipeline"
echo "Current remotes:"
git remote -v
echo "Adding GitHub remote if not exists..."
if ! git remote get-url github > /dev/null 2>&1; then
git remote add github https://$(GitHubPAT)@github.com/$(githubRepository).git
else
git remote set-url github https://$(GitHubPAT)@github.com/$(githubRepository).git
fi
echo "Updated remotes:"
git remote -v
echo "Fetching from GitHub..."
git fetch github
echo "Current branch and status:"
git branch -a
git status
echo "Pushing to GitHub..."
git push github HEAD:$(targetBranch) --force-with-lease
echo "✅ Successfully pushed to GitHub repository: $(githubRepository)"
displayName: 'Push to GitHub'
env:
GITHUB_PAT: $(GitHubPAT) # This variable comes from the GitHub-Integration variable group
- script: |
echo "=== Pipeline Summary ==="
echo "Source Branch: $(Build.SourceBranch)"
echo "Source Version: $(Build.SourceVersion)"
echo "Target Repository: https://github.com/$(githubRepository)"
echo "Target Branch: $(targetBranch)"
echo "Build ID: $(Build.BuildId)"
echo "Build Number: $(Build.BuildNumber)"
displayName: 'Pipeline Summary'
condition: always()