0
votes

I am looking for a good solution to send a specific file (or a range of files) to a private GitHub repo from Azure DevOps pipeline.

You might ask why I would like to copy a file from one git to another git. But we are using Swagger to document our API, and to show Swagger UI on Confluence it can read the swagger.json from a private repo on GitHub. As far as I know Confluence cannot read the json directly from Azure DevOps.

I've tried to use the extension GitHub Release in Azure DevOps, but I don't want to create a specific release on GitHub, I just want to update specific json files.

1
Hi, how the things going? Does the powershell task could help you achieve what you want? If yes, you can accept the answer thus other SO users will be able to see whether the solution works. If you still facing some issues, feel free to leave commend here :-)Frank Wang-MSFT

1 Answers

1
votes

You could have a PowerShell task in your pipeline to execute your requirement. Example below:

#Clone repo to your workspace
git clone https://github.com/repo

#assuming master is your branch
git checkout master

#Refresh repo if is already in your workspace
git pull -q 2>&1 | Write-Host

#Copy file to the worspace
XCOPY "File current location" "Git workspace location"

#Add files to the local repo
git add -A

#Commits the file to local repo:
git commit -m "Files commited."

#Pushes the changes to Git repo
git -c http.extraheader='AUTHORIZATION: bearer $env:System_AccessToken' push -q -f