superfly / flyctl-actions

:octocat: GitHub Action that wraps the flyctl
Apache License 2.0
261 stars 33 forks source link

Support FLY_APP environment variable #6

Closed ajsharp closed 2 years ago

ajsharp commented 2 years ago

Currently trying to conditionally set the FLY_APP environment variable in non-production branches to deploy to a staging environment, but it doesn't look like it's getting picked up:

name: Fly Deploy
on: [push]
env:
  FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
jobs:
  deploy:
    name: Deploy app
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Set fly app name
        if: ${{ github.ref != 'refs/heads/master' }}
        env:
          FLY_APP: staging-app-name
        run: echo "Setting FLY_APP=staging-app-name"
      - uses: superfly/flyctl-actions@1.1
        with:
          args: "deploy"
        env:
          ANOTHER_VAR: value
ajsharp commented 2 years ago

As it turns out, flyctl requires manual user input to override the app in the default config file, so the easier solution here is to create a separate config file for the staging environment and pass that as a flag to the args property.

jsierles commented 2 years ago

FLY_APP should be working in the latest release of flyctl. Using separate configs is also a good option!