Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
428 views
in Technique[技术] by (71.8m points)

push updates from azure to github

i am new to azure devops and facing problem to integrate between azure devops and github, may be you could help. my question is how can i push commits that are done on the azure devop repo to corresponding repo which resides on my github account?

For example: 1)i import a file abc.py from github private repo 2)i make changes to abc.py in azure devops repo and commits it. 3)now all the commits i made to abc.py on master branch of azure repo should be pushed to abc.py of master branch in my private github repo from where it was previously imported.

thanks for your help.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can try adding a Command Line Script task to the agent job of the build pipeline, and then push the update to github via the git command.

The commands added in the task are as follows:

    git clone https://github.com/XXX/XXX.git
    git config --global user.name "XXX"
    git checkout master
    git add .
    git commit -m "abc"
    git push https://%gt%@github.com/xxx/xxx.git

Here is my sample: enter image description here

Note:You need provide your github PAT in push url, like the example below:

git push https://{yourPAT}@github.com/xxx/yyy.git

To protect your PAT, you could use secure variable , such as gitHubPat, change variable type to secret. enter image description here

Then you could add an Environment Variable, in my example: gt. Then set its value to $(gitHubPat).In command line task, you use double %% to get the value of environment variable "gt".

If you need to push the updates from your azure devops repo to github repo in real time, you can set in Build Triggers and check the Enable continuous integration option.So if your master branch changes, it will trigger ci build, your update will be pushed to github repo. enter image description here

Hope this helps.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...