Question:
I have a Azure DevOps Repository that is our primary source control and GitHub Repository that is being managed by an external team. Here’s the setup:
Azure DevOps Repository: Contains Source/English.json and Source/German.json files.
GitHub Repository: Contains WorkingFolder/English.json and WorkingFolder/German.json files.
These two files are almost the same in both repository except that the English.json file is maintained by me and the German.json file in the Github is updated by the external team based on the updates that I make in English.json file in the Github repository.
Current Workflow:
Goal: To Automate this process using Azure Pipelines and Github Action so that:
Solution that I am trying:
trigger:
branches:
include:
- workingBranch
paths:
include:
- Source/English.json
variables:
branchName: 'workingBranch'
pool:
vmImage: 'ubuntu-latest'
steps:
- checkout: self
displayName: 'Checkout Azure DevOps Repository'
ref: ${{ variables.branchName }}
- script: |
git clone https://$(GITHUB_PAT)@github.com/your-org/GitTranslationRepo.git
cd GitTranslationRepo
git checkout development
cp ../Source/English.json WorkingFolder/English.json
git config user.name "your-username"
git config user.email "your-email"
git add WorkingFolder/English.json
git commit -m "Add English.json from Azure DevOps for testing"
git push origin development
displayName: 'Sync English.json to GitHub development branch'
env:
GITHUB_PAT: $(GITHUB_PAT)
Issues Encountered:
fatal: could not read Username for 'https://github.com': terminal prompts disabled.
Steps Taken:
Questions:
Any help or guidance would be greatly appreciated!
sync_to_azure.yml
file to your GitHub development
branch.trigger:
branches:
include:
- development
paths:
include:
- WorkingFolder/German.json
pool:
vmImage: ubuntu-latest
steps:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
git clone https://$(System.AccessToken)@dev.azure.com/{ADO name}/{Project name}/_git/{Azure repo name}
cd {Azure repo name}
git checkout workingBranch
cp -f ../WorkingFolder/German.json Source/German.json
git config user.name "{user name}"
git config user.email "{user email}"
git add .
git commit -m "Update German.json"
git push origin workingBranch
env:
AZURE_DEVOPS_EXT_PAT: $(System.AccessToken)
Create a pipeline in Azure DevOps.
sync_to_azure.yml
file in your development
branch.development
branch.Change settings and permissions in Azure DevOps
When you commit from WorkingFolder/German.json
in your GitHub repo, the pipeline will be triggered to push the new German.json
to your Azure repo.
azure_to_GitHub.yml
file to your Azure repo workingBranch
branch.trigger:
branches:
include:
- workingBranch
paths:
include:
- Source/English.json
pool:
vmImage: ubuntu-latest
steps:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
git clone https://$(GitHubPAT)@github.com//{GitHub Name}/{GitHub Repo name}.git
cd {GitHub Repo name}
git checkout development
cp -f ../Source/English.json WorkingFolder/English.json
git config user.name "{user name}"
git config user.email "{user email}"
git add .
git commit -m "Update English.json"
git push origin development
Change the default branch of your pipeline to workingBranch
branch.
Add a secret variable to store your GitHub PAT.