简体   繁体   中英

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.

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: 在此处输入图片说明

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. 在此处输入图片说明

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. 在此处输入图片说明

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM