superfly / fly-pr-review-apps

Github Action for PR Review Apps on Fly.io
Apache License 2.0
186 stars 116 forks source link

Error: Not authorized to deploy this app. #60

Closed glassworks-projects closed 3 months ago

glassworks-projects commented 3 months ago

Is the error I get when I try to run this workflow. I'm using the same FLY_API_TOKEN that I'm using to successfully deploy my main branch to fly. What am I doing wrong?

Full log output:

Run superfly/fly-pr-review-apps@1.2.0
/usr/bin/docker run --name b4002eff3fca8a43ea4b37b89eab5db7c947ce_07ed56 --label b4002e --workdir /github/workspace --rm -e "FLY_API_TOKEN" -e "FLY_REGION" -e "FLY_ORG" -e "INPUT_NAME" -e "INPUT_IMAGE" -e "INPUT_CONFIG" -e "INPUT_REGION" -e "INPUT_ORG" -e "INPUT_PATH" -e "INPUT_POSTGRES" -e "INPUT_SECRETS" -e "INPUT_VMSIZE" -e "INPUT_CPU" -e "INPUT_CPUKIND" -e "INPUT_MEMORY" -e "INPUT_HA" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_ENVIRONMENT" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e "ACTIONS_RESULTS_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/silk-remix/silk-remix":"/github/workspace" b4002e:ff3fca8a43ea4b37b89eab5db7c947ce
+ '[' -n  ]
+ jq -r .number /github/workflow/event.json
+ PR_NUMBER=[14](https://github.com/silknode-dev/silk-remix/actions/runs/9865416717/job/27242311710#step:4:15)
+ '[' -z 14 ]
+ GITHUB_REPOSITORY_NAME=[name]
+ jq -r .action /github/workflow/event.json
+ EVENT_TYPE=synchronize
+ app=pr-14-silknode-dev-silk-remix
+ app=pr-14-silknode-dev-silk-remix
+ region=ewr
pr-14-silknode-dev-silk-remix
+ org=personal
+ image=
+ config=fly.toml
+ grep 14
+ echo pr-14-silknode-dev-silk-remix
+ '[' synchronize '=' closed ]
+ flyctl status --app pr-14-silknode-dev-silk-remix
Error: failed to get app: Could not find App "pr-14-silknode-dev-silk-remix"
+ cp fly.toml fly.toml.bak
+ flyctl launch --no-deploy --copy-config --name pr-14-silknode-dev-silk-remix --image  --region ewr --org personal
An existing fly.toml file was found for app silk-remix
Scanning source code
Detected a Dockerfile app
Creating app in /github/workspace
We're about to launch your app on Fly.io. Here's what you're getting:

Organization: <email-address>       (specified on the command line)
Name:         pr-14-silknode-dev-silk-remix (specified on the command line)
Region:       Secaucus, NJ (US)             (specified on the command line)
App Machines: shared-cpu-1x, 1GB RAM        (from your fly.toml)
Postgres:     <none>                        (not requested)
Redis:        <none>                        (not requested)
Tigris:       <none>                        (not requested)

Error: Not authorized to deploy this app.
glassworks-projects commented 3 months ago

Figured it out; i was using the auth token generated by flyctl tokens create deploy -x 999999h, not the one generated by fly auth token; the former does not have permission to create new apps. Oversight on my part. Fixed it by storing separate tokens for my main deploy action and this action. More info here: https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/#api-tokens