superfly/docs

GH Actions Deployment instructions don't work: generated token is not usable

anatoliykmetyuk opened this issue · 8 comments

The Continuous Deployment page mentions generating a token via fly tokens create deploy -x 999999h for GitHub Actions. However, if I use that token, it doesn't work: I get the "Could not find App" error. What works is going to the personal access tokens page and generating a token from there, and using that token for GitHub Actions.

Hey @anatoliykmetyuk, just to clarify, when you ran into the error Could not find App where you in the right directory when running the command- fly tokens create deploy -x 999999h? When you "used the token", where or how were you using it?

@Lucais11 I was in the directory of the app I was deploying, that is the same directory that contains .github and fly.toml files.

"Used the token" means used it as per instruction on the website: I went to the repo secrets, created a new secret and inserted there the token generated by the command. Note that when I used the same procedure with the token generated manually from dashboard, the deployment worked.

Also note that the token generated by fly tokens create deploy -x 999999h was MUCH longer than the one generated from dashboard. The dashboard one was around one line (80 characters or so) and the one from the command took 3 lines.

@anatoliykmetyuk Thank you for clarifying all of that!

There is a difference between tokens from fly.io > dashboard > account > access tokens and tokens from fly.io > dashboard > apps > tokens on the left sidebar > create deploy token.

When running fly tokens create deploy -x 999999h you will see the deploy token in the app directory you ran the command, meaning you'll find it in fly.io > dashboard > app you ran the command in > tokens on the left sidebar > create deploy token.

So I say all this to say, if you see your deploy token for the app you ran the command for, then it got created successfully when you ran fly tokens create deploy -x 999999h. Just to double check as well, you'd want to copy the entire output meaning even the part that starts with FlyV1. Insert the entire token into the Github secret.

So I say all this to say, if you see your deploy token for the app you ran the command for, then it got created successfully when you ran fly tokens create deploy -x 999999h. Just to double check as well, you'd want to copy the entire output meaning even the part that starts with FlyV1. Insert the entire token into the Github secret.

Just checked them on the backend, and they are indeed present there. When I was trying it, I tried copying both ways, with FlyV1 and without it, didn't work both ways.

@anatoliykmetyuk Hmm interesting. When you got the token from the output of running fly tokens create deploy did you then pass that output to FLY_API_TOKEN? Here is the doc that goes into more detail here- https://fly.io/docs/reference/deploy-tokens/

@Lucais11 yes, I did. I followed exactly the steps in this guide.

@anatoliykmetyuk We've been testing this and it's been working, so I'm not sure if it was a temporary issue with deploy tokens or something else.
I realize you have it working now, but if you get the chance to try again and replace your token and it still doesn't work, then let us know!

I was deploying a different up, and tried fly tokens create deploy, and this time it worked. I followed exact same steps as I mentioned above, but this time without the -x 99999h flag. Maybe last time I typed a bit too many 9's and it overflowed? Anyway, looks like it works for me.