superfly / flyctl-actions

:octocat: GitHub Action that wraps the flyctl
Apache License 2.0
268 stars 34 forks source link

shows ‘flyctl auth login’ error when deploying application in github actions #40

Closed JuzerShakir closed 1 year ago

JuzerShakir commented 1 year ago

Describe the bug

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.

I receive this error message `No access token available. Please login with 'flyctl auth login'

Fly version: flyctl 0.0.470

My fly.toml file

# fly.toml file generated for fmb on 2023-01-01T23:25:36+05:30

app = "fmb"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[build]
  [build.args]
    BUILD_COMMAND = "bin/rails fly:build"
    SERVER_COMMAND = "bin/rails fly:server"

[deploy]
  release_command = "bin/rails fly:release"

[env]
  PORT = "8080"

[experimental]
  allowed_public_ports = []
  auto_rollback = true

[[services]]
  http_checks = []
  internal_port = 8080
  processes = ["app"]
  protocol = "tcp"
  script_checks = []
  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

  [[services.ports]]
    force_https = true
    handlers = ["http"]
    port = 80

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443

  [[services.tcp_checks]]
    grace_period = "1s"
    interval = "15s"
    restart_limit = 0
    timeout = "2s"

[[statics]]
  guest_path = "/app/public"
  url_prefix = "/"

main.yml file

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

Command output:

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.

I have already setup FLY_API_TOKEN in my github secrets.

JuzerShakir commented 1 year ago

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.