-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not able to deploy Phoenix App #22
Comments
Substituting |
fixes superfly#22 as suggested by @amos-kibet
hey @slashmili I've tried your solution but I still get the error of Here's the relevant config for my specific case:
|
@brecke unfortunately I don't have access to the project anymore and it's not possible for me to test. However just looking at your snippet, I see you are still using
While I was using
|
I stumbled on the same issue and found a bizarre solution. When I start by using Why this works is beyond me. I have reproduced the error->success flow twice now, and I'm curious if anyone else can do the same. |
@type1fool tried it but it didn't work for me. I'm getting this error Here's my current file:
Anyone knows how to solve this? Also trying on a Phoenix project |
@ricksonoliveira If you change the action back to |
@type1fool no it doesn't. I get either |
@ricksonoliveira I think this is it: environment:
name: pr-${{ github.event.number }}
url: ${{ steps.deploy.outputs.url }} You probably don't have a GitHub environment named If you point to an actual environment and use |
Hey @type1fool weird thing is, I checked my environments, and it's creating a new environment dynamically when using superfly So, I think I don't have to manually create them right? So the question would be, do I create manually a "staging" environment for instance and add a new |
This is where I think the example in the readme is possibly wrong, at least based on my understanding of GH environments. Instead of creating an environment for each PR, I defined one In the workflow, I use |
@type1fool So you did it like this?
Because this returns an error saying that staging is not a valid value |
Can you please give an example of how your script looks like @type1fool ? |
@ricksonoliveira almost!
Here's my complete name: Elixir CI
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
types: [labeled, synchronize, opened, reopened, closed]
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
env:
MIX_ENV: test
permissions:
contents: read
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: build
uses: ./.github/actions/build
- name: Save Deps Cache
id: save-deps-cache
uses: actions/cache/save@v4
with:
key: ${{ runner.os }}-deps-${{ hashFiles('mix.lock') }}
path: ./deps
- name: Save Build Cache
id: save-build-cache
uses: actions/cache/save@v4
with:
path: ./_build
key: ${{ runner.os }}-build-${{ hashFiles('mix.lock') }}
code_quality:
name: Code Quality
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/build
- name: Check Formatting
run: mix format --check-formatted
- name: Credo
run: mix credo
security:
name: Security
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/build
- name: Sobelow
run: mix sobelow --config
- name: Mix Audit
run: mix deps.audit
- name: Hex Audit
run: mix hex.audit
test:
name: Tests
runs-on: ubuntu-latest
needs: [build]
services:
db:
image: postgres:15
ports: ["5432:5432"]
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/build
- name: Run Tests
run: mix test
dialyzer:
name: Dialyzer
needs: [build]
runs-on: ubuntu-latest
env:
MIX_ENV: dev
steps:
- uses: actions/checkout@v4
- id: build
uses: ./.github/actions/build
- name: Restore Dialyzer Cache
id: restore-plt-cache
uses: actions/cache/restore@v4
with:
path: ./priv/plts
key: ${{ runner.os }}-plt-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-plt-
- name: Build Dialyzer PLTs
run: mix dialyzer --plt
- name: Save Dialyzer Cache
id: save-plt-cache
uses: actions/cache/save@v4
with:
path: ./priv/plts
key: ${{ runner.os }}-plt-${{ hashFiles('mix.lock') }}
- name: Dialyzer
run: mix dialyzer --format github
deploy_preview:
if: ${{contains(github.event.pull_request.labels.*.name, 'staging') || github.event.pull_request.merged == true}}
name: Deploy Preview
runs-on: ubuntu-latest
needs: [security, test]
environment:
name: staging
url: ${{ steps.fly-preview.outputs.url }}
env:
MIX_ENV: prod
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
FLY_APP: "pr-${{ github.event.pull_request.number }}-${{ github.repository_owner }}-top-secret"
FLY_REGION: "dfw"
steps:
- uses: actions/checkout@v4
- name: Build
id: build
uses: ./.github/actions/build
- name: Deploy
uses: superfly/[email protected]
id: fly-preview
with:
name: "pr-${{ github.event.pull_request.number }}-${{ github.repository_owner }}-top-secret"
config: fly_staging.toml
vmsize: shared-cpu-1x
postgres: top-secret-staging
secrets: |
STRIPE_SECRET=${{ secrets.STRIPE_SECRET }}
DATABASE_URL=${{ secrets.DATABASE_URL }}
SENDGRID_API_KEY=${{ secrets.SENDGRID_API_KEY }}
PHX_HOST="pr-${{ github.event.pull_request.number }}-${{ github.repository_owner }}-top-secret.fly.dev"
SENTRY_DSN=${{ secrets.SENTRY_DSN }} |
Thanks for this @type1fool. The problem with not authorized was actually my fly token not having permission, I already solved that. |
The short answer is that this repo probably needs some attention. PR #48 has some improvements for managing secrets and some other improvements. Hopefully it will get reviewed soon. Why is
I've been writing GitHub Actions / Circle CI / Travis CI config off and on for a few years now, and I have no idea why this version flipping trick is necessary or why it works. It's tempting to rewrite this action from first principles using more idiomatic GH action code, but there are higher priorities at the moment. If one were to write this from scratch, I think the requirements would be something like this:
This is how I'd approach this if I were going to write a custom action for my org, excluding the last two points. There are surely additional details to consider. It's doable, but it's not going to be easy. |
Thanks for the reply @type1fool would be very nice if someone took a look. Whilst that doesn't happen I'm working on my own script but this is being a loooot of work though. |
Just an FYI, I created this topic on fly, maybe someone will take a look https://community.fly.io/t/error-trying-to-use-fly-pr-review-action-exec-mix-executable-file-not-found-in-path-for-phoenix-app/18700 |
Mark Ericksen replied to a thread I had opened, and I've seen some activity on that PR, so it looks like this is getting some attention. |
Yea, I tried replying to that thread to ask him if he got the time to take a look but it's closed. I didn't notice it was your thread though, neat! Hopefully someone will take a look on this soon, I don't want to reinvent the wheel here but it's sounding like a completely different approach will be needed if no ones fixes this. |
Hey Guys! Just passing here to let you all know that I found a way to make this work for Elixir Phoenix Applications! 🎉 I have to say the solution may not be the best but it does work! |
I was able to workaround that error adding the with:
image: elixir:1.16 I can now deploy the web server as expected. EDIT: Everything works, including the database attach part yay! 🥳 What I lack the most right now is having a |
I'm running into issues with my phoenix applications as well, when waiting for the health check it looks like my machine gets stuck at
Does anyone know what I might be doing wrong here? |
I'm running [deploy]
release_command = "/app/bin/migrate" And it runs okay. Hard to be of help without more info on your side, but the diagnosis is pretty clear: somehow it ends up in a place where it cannot access Let me know how I can help. |
Thanks @brecke, I'll provide a bit more information. So this is my github action
and this is my fly (I liked the idea of a preview config, so I stole that :P)
I'll continue to dig and see if I can provide some more information. |
I think it comes down to the container just not having the So let's find out whether the path exists: docker run -it --rm elixir:1.16 bin/sh
...
# ls -la /app/bin/migrate
ls: cannot access '/app/bin/migrate': No such file or directory So there you go. In my case, I am building my own image on a previous step on the workflow - name: Build elixir image
run: docker build -t custom-image-elixir:1.16 -f Dockerfile . and then, later, I use it later, just like you did: image: custom-image-elixir:1.16 Now you may be wondering what's my Dockerfile like. Well, I stole it too from Fly-apps repo here. You'll notice the Building my container in the GA workflow is kind of hacky, but I don't think there's a better way unless publishing it on dockerhub (and then providing the name in the Hope this helps. |
Okay that helped me get a little further 😅 but it seems I need a degree to work with flyio's API HA. I'm getting this error now
Also the postgres option doesn't seem to work as intended because I need to explicitly pass a DATABASE_URL 😕. |
Regarding the postgres part, I don't pass any postgres: yourapp-db-preview As for the release failing, I suggest you check the logs as suggested, but it doesn't seem to be a problem with the GA anymore, I'd say. |
This reverts commit 11c6086. For context: superfly/fly-pr-review-apps#22 Signed-off-by: Jan Ehrhardt <[email protected]>
Hey guys, allow me to share a small update which might be useful to someone: I had this problem where I'm using a custom image (see above) to build and deploy my app along with postgres. I found out two things
So I eventually ended up doing this:
- name: Get code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Install flyctl CLI
uses: superfly/flyctl-actions/setup-flyctl@master
- name: Authenticate with Fly.io registry
run: flyctl auth docker
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
- name: Create Fly App before pushing docker image to registry
run: |
flyctl apps create ${{ env.APP_NAME }} --org ${{ env.FLY_ORG }} || true
flyctl postgres attach mycompany_preview_db_app --app ${{ env.APP_NAME }} || true
env:
FLY_API_TOKEN: ${{ secrets.FLY_AUTH_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
push: true
tags: registry.fly.io/${{ env.APP_NAME }}:your_version
context: .
- name: Deploy PR app to Fly.io
id: deploy
uses: superfly/[email protected]
with:
name: ${{ env.APP_NAME }}
config: my_preview_config.toml I also managed to automatically seed the database and manage Cloudflare DNS records automatically. I asked Claude to summarize it in case someone has questions:
Hope this helps other people. |
I'm trying to use this GithubAction in my Phoenix app.
The problem is in this line
fly-pr-review-apps/entrypoint.sh
Line 40 in 5d5f1c2
flyctl
attempts to executemix
but since mix is not installed in the docker container, it fails.In addition there are multiple problems with the current main which makes this GithubAction unusable at least for my use case .
I forked the repo and move the main code to
index.js
, you can find it at https://github.com/slashmili/fly-pr-review-apps/blob/nodejs-action/index.jsI'm using it in my project like:
This way by the time that
Deploy
step is getting executed, already Elixir and mix is installed canflyctl
commands can use the mix command.If you are interested in maintaining the upstream, I'd purpose that take the same approach. I'm not familiar with node so take my changes with grain of salt.
The text was updated successfully, but these errors were encountered: