Forum Discussion

AsimKhan2023's avatar
AsimKhan2023
Brass Contributor
Feb 01, 2024

Deploying code to GitHub via Azure DevOps Release Pipeline

Hi,

 

I created an Azure DevOps project and in the repository I acquired the repo from GitHub, with PAT which worked perfectly and without any errors. I coded the project in Visual Studio 2022 and then pushed my code to Azure DevOps repo. Now the coding is completed along with the PR exercise. I created a build pipeline that worked perfectly and passed successfully. I then started working on the release pipeline, with the intention of deploying or passing my code from the Azure DevOps repo to GitHub repo. I installed the necessary application such as Azure Pipelines from the GitHub marketplace. I am trying to create a release pipeline to deploy code, but every time I run the release pipeline it throws an authentication error that prevents the code to be deployed to the GitHub repo even though the PAT information is correct. Kindly let me know where I went wrong with this.

 

Regards,

Asim Khan

1 Reply

  • AsimKhan2023's avatar
    AsimKhan2023
    Brass Contributor
    The issue has been resolved and now the code has been pushed from Azure DevOps to GitHub repo.

    I applied the following steps as guided:

    Deleted the PAT from Azure DevOps and GitHub repo
    Created a new PAT for both environments
    Made copies of both PATs from the environments

    Used the following script to make the release pipeline

    script: |

    Clone Azure DevOps repository
    git clone https://<Azure-DevOps-PAT>@<Azure-DevOps-Repo-URL> MyRepo

    Change into the cloned Azure DevOps repository directory
    cd MyRepo

    Add GitHub repository as a remote
    git remote add github https://<GitHub-PAT>@<GitHub-Repo-URL>

    Fetch changes from Azure DevOps to update local repository
    git pull origin master --rebase

    Reset local branch to the state of the Azure DevOps repository
    git reset --hard origin/master

    Push changes to GitHub repository with force to overwrite existing content
    git push -u github master --force
    displayName: ‘Copy Code to GitHub’

    The script worked perfectly and the code from the Azure DevOps pushed to GitHub repo.

    Regards,
    Asim Khan

Resources