swellaby / vsts-mirror-git-repository

A straightforward utility to mirror one Git repository to another location
MIT License
25 stars 15 forks source link

Azure DevOps - Heroku #121

Open renerlemes opened 1 year ago

renerlemes commented 1 year ago

Question Could someone provide an example of how to use it with integration with Azure DevOps and Heroku?

calebcartwright commented 1 year ago

Fundamentally this task operates at the git level, and all that's really needed is the set of remotes and any associated authentication. I know Heroku supports git pushes as a means of deployment, but I'm not familiar with what the auth story looks like when using git directly with Heroku.

However, I'd be curious to understand more about your use case because at first blush it doesn't seem like a typical one for this extension. I'd view Heroku as some form of a deployment target as opposed to a general purpose git repo host/remote, and one where you'd want to focus on pushing changes for a specific branch to Heroku as part of an intentional deployment, as opposed to performing a git mirror operation to get all refs from one repo source to another

renerlemes commented 1 year ago

Heroku works with buildpacks, depending on the language of the project that the repository is in. But generally speaking, when a push is received on Heroku's master/main branch, it automatically deploys it to its environment and makes the application available. I tried using the extension as follows:

image image

The commands I did manually and it worked were these:

git clone --branch main https://$(System.AccessToken)@$(azure.gitUrl) cd [folder] git remote rm origin git remote add --mirror=fetch origin https://heroku:$(heroku.apiToken)@git.heroku.com/$(heroku.appName).git git fetch https://$(azure.pat)@$(azure.gitUrl) git push origin --all -f

But I couldn't use the extension

calebcartwright commented 1 year ago

I've used Heroku a bit in the past for various projects so have some familiarity, but I still feel like you didn't address the question from my prior comment. Specifically, I'd like to understand why you'd want to use a git mirroring task for deploying to Heroku as opposed to say, the Heroku cli or the Azure DevOps Extensions for Heroku.

Either way, there's not really enough information here for us to assist you, and it's not something we will try to pursue in parallel given the semi-recent Heroku/Salesforce announcement about dropping free tiers.

The only thing I could suggest you review is the value of the $(HerokuGitUrl) variable in your pipeline as shown in your screenshot of the usage of this task. It should be https://git.heroku.com/$(heroku.appName).git

renerlemes commented 1 year ago

The two extensions available on the Marketplace for Azure DevOps Server don't work, both don't show your tasks to be used. As for using Heroku Cli, I haven't tried using Azure Pipeline yet. So the only way I found to work was doing everything with git commands.

Actually the variable was wrong in the Destination Git Repository field and also in the Destination Repository - Personal Access Token field. But unfortunately your suggestion didn't work either.

Now at least the variables are all with the correct values as the repositories are accessed.

The current error I'm having would be the one below:

image