add fly.io PR review apps (#9069)
* add fly.io PR review apps * add fly.toml to dockerignore * merge branch instead of applying diff --------- Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
This commit is contained in:
10
.github/scripts/cleanup-review-apps.sh
vendored
Executable file
10
.github/scripts/cleanup-review-apps.sh
vendored
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euxo pipefail
|
||||
|
||||
apps=$(flyctl apps list --json | jq -r .[].ID | grep -E "pr-[0-9]+-badges-shields") || exit 0
|
||||
|
||||
for app in $apps
|
||||
do
|
||||
flyctl apps destroy "$app" -y
|
||||
done
|
||||
35
.github/scripts/deploy-review-app.sh
vendored
Executable file
35
.github/scripts/deploy-review-app.sh
vendored
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euxo pipefail
|
||||
|
||||
app="pr-$PR_NUMBER-badges-shields"
|
||||
region="ewr"
|
||||
org="shields-io"
|
||||
|
||||
# Get PR JSON from the API
|
||||
# This will fail if $PR_NUMBER is not a valid PR
|
||||
pr_json=$(curl --fail "https://api.github.com/repos/badges/shields/pulls/$PR_NUMBER")
|
||||
|
||||
# Attempt to apply the PR diff to the target branch
|
||||
# This will fail if it does not merge cleanly
|
||||
git config user.name "actions[bot]"
|
||||
git config user.email "actions@users.noreply.github.com"
|
||||
git fetch origin "pull/$PR_NUMBER/head:pr-$PR_NUMBER"
|
||||
git merge "pr-$PR_NUMBER"
|
||||
|
||||
# If the app does not already exist, create it
|
||||
if ! flyctl status --app "$app"; then
|
||||
flyctl launch --no-deploy --copy-config --name "$app" --region "$region" --org "$org"
|
||||
echo $SECRETS | tr " " "\n" | flyctl secrets import --app "$app"
|
||||
fi
|
||||
|
||||
# Deploy
|
||||
flyctl deploy --app "$app" --region "$region"
|
||||
|
||||
# Post a comment on the PR
|
||||
app_url=$(flyctl status --app "$app" --json | jq -r .Hostname)
|
||||
comment_url=$(echo "$pr_json" | jq .comments_url -r)
|
||||
curl "$comment_url" \
|
||||
-X POST \
|
||||
-H "Authorization: token $GITHUB_TOKEN" \
|
||||
--data "{\"body\":\"🚀 Updated review app: https://$app_url\"}"
|
||||
Reference in New Issue
Block a user