'flyctl auth login' error is shown when deploying application in github actions

So I want to deploy my ruby on rails application after all the test passes to fly.io, so I followed the instructions in this document but it doesn’t seem to work.

Here’s the error received by github-actions:

> Run flyctl deploy --remote-only
  
Error No access token available. Please login with 'flyctl auth login'

Error: Process completed with exit code 1.

My main.yml file:

    deploy:
        needs: rspec-test
        runs-on: ubuntu-latest
        env:
            FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
        steps:
            - uses: actions/checkout@v3
            - uses: superfly/flyctl-actions/setup-flyctl@master
            - run: flyctl deploy --remote-only

I have already setup FLY_API_TOKEN in my github secrets.

Any solutions?

I just ran through the instructions successfully with a new Rails application, and was able to deploy:

image

I made some minor formatting and clarifications to that page. The secret needs to be a Repository secret, and the current recommendation is to set the environment variable only on the deploy step.

Double check that you didn’t make any copy/paste errors or typos perhaps?

1 Like

Ok, so I mistakenly added FLY_API_TOKEN secret to an ‘Environments secret’ instead of adding it to the ‘Repository secret’ and that’s the reason why it couldn’t access the secret as it was looking in the ‘Repository secret’, hence the error, No access token available.

Silly Me! Thanks for the heads up on that!

I had a similar issue. The solution I found was by adding the name of your environment that contains the secret. Example using the environment name production below:

name: Fly Deploy
on:
  push:
    branches:
      - main
env:
  FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
jobs:
deploy:
    name: Deploy app
    runs-on: ubuntu-latest
    environment: production
    steps:
      - uses: actions/checkout@v3
      - uses: superfly/flyctl-actions/setup-flyctl@master
      - run: flyctl deploy --remote-only

I see this isn’t the preferred method following an update of the docs, sharing nonetheless for general knowledge.

1 Like

Nothing wrong with that approach. I added a note to the doc page saying that this is an option.

2 Likes