-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
add fly.io PR review apps #9069
Conversation
.github/scripts/deploy-review-app.sh
Outdated
|
||
# Attempt to apply the PR diff to the target branch | ||
# This will fail if it does not merge cleanly | ||
curl --location "$(echo "$pr_json" | jq .diff_url -r)" | git apply |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to clarify: This will fail to deploy a review app if there is a merge conflict.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm having a bit of deja vu so apologies if this has been asked and answered before, but is there any reason we wouldn't want to check out the PR ref directly? I.e.
git fetch pull/$PR_NUMBER/head:pr-$PR_NUMBER && git checkout pr-$PR_NUMBER
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we've discussed it before.
At this stage, there is a very pragmatic reason why I'm doing it this way: There is no open PR which has these files in the source branch yet. So if I check out the source branch for any existing PR, fly.toml
won't be on it. Merging the PR source branch into the working branch allowed me to test this workflow on some real PRs.
Once we get to the stage where all the open PRs are based off a master branch that has these files on it, it might make more sense to check out the branch directly. That would also allow us to deploy review apps for PRs where there is a merge conflict.
I think in the first case, being able to use this on existing open PRs is useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing I realised when I tried to make a preview app for #9014 was that applying the diff doesn't work if there are binary files in it.
I've switched to merging the source branch in 9d93b98 (which solves that, but will still fail if there is a conflict), but still sticking with merging for now for the reason above (no open PRs have this code on the source branch yet)
fly.toml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the creation of this file have the potential to impact any of other workflows/processes? (e.g. the staging/prod apps)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our existing fly.toml
s live elsewhere and just says "grab an image from DockerHub and deploy it". Its shieldsio/shields
but it could be any old image on DockerHub so what's in this repo only really impacts anything to the extent that the code in it is in the docker image we deploy.
Adding this here does mean if you were to flyctl launch
from the root of this repo, that would create an app called shields-io-review-apps
(which doesn't currently exist in our account). If we don't want it in the root, I think we could also move it somewhere else (maybe under .github
) and specify the path to the config file in deploy-review-app.sh
with the --config
arg.
You have made me think this doesn't need to go in the docker image though, so I've added it to .dockerignore
in f8baf18
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple questions but otherwise lgtm
This comment was marked as outdated.
This comment was marked as outdated.
1118ad6
to
9d93b98
Compare
closes #7924
closes #8337
We lost access to Heroku review apps, but they were very useful 😭
I had a look into https://github.com/superfly/fly-pr-review-apps but this only works on PRs from branches on the source repo (not PRs from forks) because a fly token must be exposed to the workflow. Even if we could expose a fly.io token to PRs from forks, we really don't want to do that.
This PR is based on the code in https://github.com/superfly/fly-pr-review-apps but adapted for our needs. Merging this PR will give us a workflow which we can trigger manually. We give it a PR number when we trigger it and that will create or update a review app for us using fly.io. Some notes: