Elixir PR Staging Preview

Heyo!

I followed the Staging environments on the Fly with GitHub actions guide, and I have the GitHub action up and running. However, I appear to need another step to make the preview deploy successful. Since superfly/fly-pr-review-apps differs from superfly/flyctl-actions/setup-flyctl, I’m not sure what to do.

+ '[' -n  ]
+ jq -r .number /github/workflow/event.json
+ PR_NUMBER=72
+ '[' -z 72 ]
+ [REDACTED]
+ jq -r .action /github/workflow/event.json
+ EVENT_TYPE=synchronize
+ [REDACTED]
+ [REDACTED]
+ region=dfw
pr-72-[REDACTED]
+ org=personal
+ image=
+ config=fly_staging.toml
+ echo pr-72-[REDACTED]
+ grep 72
+ '[' synchronize '=' closed ]
+ flyctl status --app pr-72-[REDACTED]
Error: failed to get app: Could not find App "pr-72-[REDACTED]"
+ cp fly_staging.toml fly_staging.toml.bak
+ flyctl launch --no-deploy --copy-config --name pr-72-[REDACTED] --image  --region dfw --org personal
An existing fly.toml file was found for app [REDACTED]
Error: We've identified an Elixir Project but when attempting to compile it we ran into an error. Please check that your Elixir project builds successfully and try again.: exec: "mix": executable file not found in $PATH

Also, I noticed that this deploy was triggering before CI was complete. To my mind, the staging deploy should only be triggered after a successful CI run, so I tried using a trigger from my prod deploy action:

on:
  workflow_run:
    workflows: ["Elixir CI"]
    types:
      - completed

However, this doesn’t trigger the staging action even when the Elixir CI workflow completes successfully.

TLDR:

  1. How do I deploy an Elixir app to a PR preview machine using superfly/fly-pr-review-apps?
  2. How can I ensure that staging deploys are only triggered after CI passes?

Thank you for the article, Mariusz. :wave:

1 Like

@Mark :wave:

I’d love to see a new doc or blog article on this, fwiw. :crossed_fingers: I skimmed Phoenix Files and the docs but didn’t see any Elixir-specific articles about using fly-pr-review-apps.

Re: workflow_run
I dug a bit deeper into the GitHub actions documentation and found that the workflow_* events only trigger on a repo’s default branch. So, that answers the second question. I moved the staging deploy step to my CI workflow and made it wait for build, test, and security steps.

The app still doesn’t deploy successfully, and it continues to produce this error (formatted for clarity):

Error: We've identified an Elixir Project but when attempting to compile it we ran into an error.
Please check that your Elixir project builds successfully and try again.:
exec: "mix": executable file not found in $PATH

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

Hi @owen!

Yes, the PR review feature is something I want to focus on soon. Actually, I’m hoping to start experimenting with it again in the next week or so. :slight_smile:

2 Likes