Heroku: how to clone or create team app? - heroku

I've created a Team in Heroku and now I'd like to create an app inside that team from the cli, but there seem to be no team related cli flags.
I'm basically hoping for something like:
heroku create myteamapp --org myteam
I could also create the app in the online dashboard, but when I do that and I clone the app I can't push for some reason. What I did (I suplemented names for fake names):
$ git:clone -a myteamapp
Cloning into 'myteamapp'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.
$ git remote -v
heroku https://git.heroku.com/myteamapp.git (fetch)
heroku https://git.heroku.com/myteamapp.git (push)
$ git push heroku master
error: src refspec master does not match any.
error: failed to push some refs to 'https://git.heroku.com/myteamapp.git'
The app is listed when I run heroku apps --org myteam.
The info that heroku info returns seems valid, the Git URL matches the remote url, the region is eu, which I configures in the online dashboard.
My user is listed as admin in the access section of the online dashboard for that app.
There was no team relevant docs in:
devcenter.heroku.com/articles/creating-apps
devcenter.heroku.com/articles/git-clone-heroku-app
There was no cli relevant docs in:
devcenter.heroku.com/articles/heroku-teams

I should have checked heroku help create. This lists -o or --org as flags to specify the organization.
The errors I got after trying that,that confused me where related to git; I didn't have any commits yet.

Related

heroku deployment error [Item could not be created: Unauthorized] [duplicate]

This post relates to a rapidly changing event.
I simply want to connect to my GitHub account. When I do it, I get this error message as a small red pop up on the upper right side of the page:
Items could not be retrieved, Internal server error.
As of May 25, 2022, at 19:52 UTC, GitHub integration has been re-enabled:
We are happy to report that the GitHub integration is re-enabled! You can now reconnect with GitHub and restore your Heroku pipeline functionality, including Review Apps, with newly generated tokens.
You can connect to GitHub immediately or wait for the enhanced integration as described in this blog post. To re-establish your GitHub connection now, please follow these instructions.
Here is what the referenced blog post says about "enhanced integration":
In an effort to improve the security model of the integration, we are exploring additional enhancements in partnership with GitHub, which include moving to GitHub Apps for more granular permissions and enabling RFC8705 for better protection of OAuth tokens. As these enhancements require changes by both Heroku and GitHub, we will post more information as the engagement evolves.
No timeline is mentioned for availability of the enhanced integration.
Between April 15 and May 25, 2022, Heroku's GitHub integration feature was disabled while Heroku investigated a security breach. During that time, deploying was still possible via other means, most notably via git push.
To mitigate impact from potentially compromised OAuth tokens, we will revoke over the next several hours all existing tokens from the Heroku GitHub integration. We are also preventing new OAuth tokens from being created until further notice. Your GitHub repositories will not be affected in any way by this action.
Which Heroku features have become non-operative due to the removal of the Heroku-GitHub integration?
Enabling review apps
Creating (automatic and manual) review apps
Deploying (automatic and manual) review apps
Deploying an app from GitHub (either manual or automatic)
Heroku CI cannot create new runs (automatically or manually) or see GitHub branch list
Heroku Button: unable to create button apps from private repositories
ChatOps: unable to deploy or get deploy notifications
Any app with a GitHub integration may be affected by this issue. To address specific integration issues, please open a case with Heroku Support
Migrating from GitHub deployment to Git deployment
At 2022-04-21 23:53 UTC, Heroku provided extended instructions for migrating from GitHub-based deployment to Git-based deployment:
While our customers remain unable to reconnect to GitHub via the Heroku dashboard, we wanted to share a supplement to the code deployment methods previously provided. For instructions on how to change your deployment method from GitHub to Heroku Git, please refer to the following Help article: How to switch deployment method from GitHub to Heroku Git with all the changes/app code available in a GitHub repo.
This is due to an issue reported at their status portal, here.
For now, the solution is to use another pushing strategy.
The best one, for now, is using their remote with Heroku CLI. The steps for it are:
1. Install the Heroku CLI if not yet installed
Further information about installation and setup can get here
2. Perform login with the heroku login command
You will be prompted with your default browser window for completing the login at the Heroku portal.
3. Assuming you already have your app set up at Heroku (if not, please follow this), you just need to add a new remote for your Git repository with Heroku CLI.
Run heroku git:remote -a example-app - substitute "example-app" with your app name.
4. git remote -v to check if the remote has been set successfully
You should see something like this appear as a response:
heroku https://git.heroku.com/your-app-name.git (fetch)
heroku https://git.heroku.com/your-app-name.git (push)
5. Push your branch to the new heroku remote
git push heroku your_branch_name
6. You should see the progress of your deployment being displayed in the terminal
The reference for this answer has been taken from here, which can also be used if further information other than the one provided in this answer is needed.
I'm in the same situation, and, as others stated, it's due to a Heroku security issue. In the meantime, you can deploy your code by using the Heroku CLI.
So, on the Heroku web dashboard, select Heroku Git:
Then set up the Heroku CLI with heroku login.
Finally, if your repository already exists on GitHub, you need to add a new remote by running:
heroku git:remote -a your_app_name
git push heroku master
You can find more information about this solution in the official documentation.
It is just a temporary thing, and more details about this issue are here.
You could push to both GitHub and Heroku at once for a temporary solution:
git push -u origin <branch>
git push heroku <branch>
I see the previous answers, but since I was facing an issue with review-apps (PR apps), mostly you will be working with different branches in that case, so here is a solution for pushing your stuff other than the (master/main) branch to Heroku.
First make sure your remote origin is set up correctly
heroku git:remote -a your_awesome_app
You can also confirm it by git remote -v and you should see your origin pointing to your Heroku application.
git remote -v
heroku https://git.heroku.com/your_awesome_app.git (fetch)
Here origin name is heroku.
If you want to deploy your changes from the main branch
git push heroku main
If you want to push your changes from feature branch (other than the* main branch)
Then push your feature branch to Heroku using the below command
git push heroku feature:main
heroku - is your origin name (confirm your origin name with git remote -v
feature - is your current branch which is other than main/master branch (check your branch name with git branch or git status)
For those who are using this integration for deployment purposes this, I suggest you use the deploy to a Heroku GitHub action here:
Deploy to Heroku
That way, you do not have to make significant changes to your deployment workflow.
I had the same issue. I already had cli installed.
git remote
Output:
heroku
origin
git remote -v
Output:
heroku https://git.heroku.com/YOUR-APP.git (fetch)
heroku https://git.heroku.com/YOUR-APP.git (push)
origin https://github.com/GitUserName/yourRepo.git (fetch)
origin https://github.com/GitUserName/yourRepo.git (push)
Verify using the Git branch, if your branch is named main. For example, you would do:
git push heroku main
For me it is
git push heroku master
Now push your local changes
git push heroku master
Output:
To https://git.heroku.com/YOUR-APP.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://git.heroku.com/YOUR-APP.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
I do not care that it is different than its remote. I've been developing locally and did not realize the automatic Git deploys had been failing. I care about the local changes:
git push heroku master -f
Now the deployed application is working as expected.
If you are getting an error while trying to push, it may be due to having different branch names for development vs deployment. In such a case, follow the instruction below;
If you are developing on a branch and deploying via Git you must run:
git push heroku <branchname you're developing on>:<branch you're deploying from>
This article goes into details on the behavior:
Duplicate Build Version Detected
Here's the easy work pattern I have used for Heroku. This is intended to help others who may not have gone through this before. I used this previously (2014-5) and had to set it up again last night to push.
First add the Heroku remote:
git remote add heroku https://git.heroku.com/YOUR-APP.git
As GitHub is often "origin" (git push origin...), this adds another remote destination, "heroku" (git push heroku...)
git remote
Output:
heroku
origin
My pattern for code/git/pushing:
Local development is the same. Push to GitHub, merge, and nothing changes.
Set your deploy to "Heroku git" as #a-chris outlines.
To push to Heroku, simply push the correct branch to the newly added "heroku" remote source. I use the --force option to dismiss any possibility of conflict. Unless you have been using Heroku Git and branching previously, there should only be one branch - typically "master" to use.
This will trigger a deploy. You can watch or review in the dashboard as well as the terminal. Treat the new "heroku" source as a directory to dump code to promote and not a repository you want to keep history, etc. A second-class citizen in this particular pattern.
I push from my local terminal now instead of auto-deploy or via the dashboard button. If your organisation is large, I recommend controlling access. Many developers may not have experience juggling multiple destination repositories or to catch an accidental push.
To trigger a local push, be sure your master (or whatever) is up to date...watch your commit hashes!
This will set you up to follow advice such as BR19_so and others.
Henrique Aron's answer is working for the local machine.
For a remote SSH server, you will face an IP mismatch error.
To resolve it:
Log in to the Heroku website
Go to account settings
Reveal the API keys in the panel
In the server CLI, type heroku login -i
Input email, use the API key as the password, and you can follow the rest of the steps of a Git remote push
I am using a 2014 MacBook Pro with macOS 11.6.5 (Big Sur) version for command
brew tap heroku/brew && brew install heroku
I was getting an error and a message to update to the latest Xcode. The latest Xcode needed the latest macOS, which I could not upgrade to (I needed a 2015 MacBook Pro or newer). For a 2014 MacBook Pro, I was able to Install Xcode_13.2.1.xip and was able to run. Now I can push updates to Heroku.
brew tap heroku/brew && brew install heroku
There is an update regarding this issue. You can now enable GitHub integration as mentioned in the update.
If it doesn't work, you can try removing the App connection to GitHub (disconnect) and adding the connection again. Adding the connection again can also be done in incognito mode because sometimes an issue occurs related to cookies (mentioned here).

How to check if my repository has been deployed to heroku?

I have several repositories and only one has been deployed to heroku. How do I find out which one? Because I made a change in one repo and tried to push it but got a warning fatal: 'heroku' does not appear to be a git repository. Is there a command?
It looks like you have not created heroku repository yet or you are in wrong directory. Go to the directory where you have your app then create heroku with the help of below commands.
git init
heroku create
after creating heroku you can add and commit heroku with the help of
git add .
git commit -am "any comment"
last step will be to push all your data to heroku server by
git heroku push master
If repository is already created, you can check associated repository by hitting below command
$ git remote -v
You may need to run heroku git:remote command to associate a Git repository with an existing application
for more information on how to deploy app click here

Don't have access to Heroku app

I have a mystery app in Heroku. It's called weird-app-5536
When I try to push my code to Heroku I get this message:
Your account my_email#geemail.com does not have access to weird-app-5536.
!
! SSH Key Fingerprint: *************************************************
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
When I try...
heroku apps
I get a list of my apps, but it does not include the mystery app, weird-app-5536.
I can't destroy or rename the weird-app-5536 app. It always says I don't have access.
The app does not appear on my list of apps on the Heroku website.
When I type
git remote -v
I get this:
heroku git#heroku.com:weird-app-5536.git (fetch)
heroku git#heroku.com:weird-app-5536.git (push)
origin git#github.com:thisisme/my_code.git (fetch)
origin git#github.com:thisisme/my_code.git (push)
I deleted my old ssh keys. I created a new one and added it to Heroku
I can create new apps and they show up on my list of apps.
As far as I know I only have one Heroku account.
Stumped. I don't know where to go from here.
What's happened is the git repo on which you're working is tied to an old remote. No need to contact heroku or anything... Just remove the heroku git remote and readd it.
Remove by running:
git remote rm heroku
Readd with:
heroku git:remote -a appname
More here: https://devcenter.heroku.com/articles/git
Honestly, I would try to get a hold of Heroku support. It might be possible that you were listed as a contributor to another app by someone but weren't given write access? Heroku support is probably your best bet.

How to attach my repo to heroku app

I create a heroku app and then my machine crashed. I have a new machine. How do I attach my existing app to heroku app. When I visit heroku page the url for my app is like this
git#heroku.com:myapp.git
I can't do clone this app because I already have myapp from github. So I need to add heroku as remote to my existing github app. Anyone knows the syntax.
If you've heroku toolbelt:
If you're using the Heroku Toolbelt, the newer syntax is
heroku git:remote -a project
See this for more.
Credits: user101289's solution
Else if you don't have heroku toolbelt:
First do this:
git remote add heroku git#heroku.com:{heroku-app-name}.git
Then do this:
git push heroku master
heroku open
If you're using the Heroku Toolbelt, the newer syntax is
heroku git:remote -a project
See this for more.
If you're using just Git without installing the Heroku Toolbelt, you can also create a new application.
Login to your account and go to this link
https://dashboard.heroku.com/apps
Look at the plus sign on the top right corner then select
Create new app
Leave the application name blank to let heroku choose one for you.
Let say your heroku app name is new-app-xxxxx, so to test on adding a file in to it you may try the following command:
git clone https://git.heroku.com/<new-app-xxxxx>.git
cd <new-app-xxxxx>
echo "my test file" > test.txt
git add .
git commit . -m "my test on commit"
git push
Put empty (blank) when the Git prompt for username, and your API Key for the password. You can get your API Key by showing it from the link below.
https://dashboard.heroku.com/account
Note: You cannot authenticate with the Heroku HTTP Git endpoint using your Heroku username (email) and password. Use an API key as described here.

How can I pull an existing heroku app to new location for development?

I currently have the latest version of my code on another computer that I want to develop from (Home computer and laptop for when I'm out and about) I set up heroku for my app on my laptop. Now I need to associate my code on my desktop so that I can push to heroku from there as well.
This is what I get from my desktop:
desktop:~/NetBeansProjects/onlinescheduler$ git pull heroku master
fatal: 'heroku' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
I can't do heroku create because that will create a separate app. How do I associated the existing code with (or pull down a brand new version from) heroku?
Whats the command to do this?
Also, If you've never used heroku before on the other machine, you'll need to do a few more things first:
$ gem install heroku
$ heroku login
[then enter your credentials]
$ heroku keys:add [path to keyfile]
Now you can clone the remote repository:
$ git clone git#heroku.com:<heroku_app>.git <local_directory>
First of all, you'll want to follow the Quick Start instructions for Heroku, which you can get straight from the horse's mouth, right here: https://devcenter.heroku.com/articles/quickstart
Once you've gotten through step 3, come back here.
Then, you can type this into the command line:
heroku git:clone -a myapp
This is described here:
https://devcenter.heroku.com/articles/git-clone-heroku-app
Then, if you want to grab the database too, here are some options.
Newer Heroku instructions on import/export:
https://devcenter.heroku.com/articles/heroku-postgres-import-export
Older heroku instructions on push and pull: https://blog.heroku.com/archives/2009/3/18/push_and_pull_databases_to_and_from_heroku
If you are using mongo, this is a useful tool to sync your mongo database: https://github.com/pedro/heroku-mongo-sync#readme
If you first need to get the app from Heroku, clone your app.
To do that, write in your Terminal:
heroku git:clone -a your_app_name
If you already have the app and the remote to heroku follow the next steps. If not, you can check instructions here https://devcenter.heroku.com/articles/git
Find the name of your database
Write in your Terminal:
heroku pg:info -a your_app_name
it will look something like this:
HEROKU_POSTGRESQL_MAROON_URL
Find the name of your local database
In your Rails app go to config/database.yml
it will look something like this:
your_app_name_development
Clone your production database (PostgreSQL)
Write in your Terminal with your own database names:
heroku pg:pull HEROKU_POSTGRESQL_MAROON_URL your_app_name_development -a your_app_name
HEROKU_POSTGRESQL_MAROON_URL is an example of how could be the name of your production database (in Heroku):
my_app_name_development is the name of your development database (locally)
the_name_of_my_app is the name of your app in Heroku
Don't forget to finish this with bundle install...
If you already have your code base ready and have heroku setup, use:
$ heroku git:remote -a your_heroku_app
This will allow you to deploy from your new location.
Reference: https://devcenter.heroku.com/articles/git#creating-a-heroku-remote
Once you create a key in a new computer, you have to upload your new SSH key by typing heroku keys:add.

Resources