-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
Automate checkout, deploy, and --site
+ --base
config
#29
base: main
Are you sure you want to change the base?
Conversation
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.
lgtm!
If this is working maybe you look into merging? |
@KorigamiK If you want to try this PR while we're working on it, you're welcome to point your repository to it! Using |
--site
+ --base
config
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 think this is great!
One thing I’ll say regarding automatic base
is that users probably still want to set base
in their config in most cases. Otherwise while developing locally you have a base of /
and links using /github-base/
will 404. Saw this confusion in withastro/starlight#804 for example where a user deploying to GH Pages had manually set:
base: process.env.CI ? '/github-base/' : undefined,
making it impossible to get links working in both places.
I don’t know if that makes setting base
automatically less attractive or not. Would still work well for people who mostly don’t work locally.
action.yml
Outdated
$RUNNER astro build \ | ||
--site "${{ steps.pages.outputs.origin }}" \ | ||
--base "${{ steps.pages.outputs.base_path }}" |
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 can understand the hesitation here is it makes customisation of the build step impossible (no way to run pre/post scripts as well for example).
I guess adding an input that tells us the build command risks not working with automatic --site
and --base
flags if someone’s package script is not the right form? (e.g. something like "build": "astro build && node ./post-build"
)
Some options off the top of my head:
- Add
prebuild
/postbuild
inputs for scripts to run either side of the build - Add default steps that do this “automatically” (
npm run prebuild --if-present
— maybe no Yarn support?) - Just add a single build command input that overrides our clever automatic one — up to a user to configure site/base correctly if they decide to override for some reason.
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.
Yeah I was checking how Vercel does this, and they phrase it as "overrides," which makes sense. actions/configure-pages
also has an interesting approach where they override the values in the config file after cloning. So that's maybe a more fool-proof method.
Of course, if Astro accepted ASTRO_SITE
and ASTRO_BASE
env variables, that could work too. Or we could just publish a GitHub Pages integration that automatically wires those two values for you?
Many ways to tackle the problem!
d9cee9a
to
2a8ed56
Compare
Based on https://github.com/actions/configure-pages, automatically infer the correct `--site` and `--base` flags for Astro to use when building. Also adjusts `npm install` to use `npm ci` and switches away from using the default `build` script to instead use the `npx --no-install astro build`. Unsure if this is a good idea.
2a8ed56
to
4e1a5b3
Compare
Looking forward to test this @natemoo-re 💯 what did I miss here? https://github.com/ollegkz/olle.coffee/actions/runs/7401803673/job/20138353320 |
That is probably on my end! I'm guessing the command is not correct so Bun is printing its help message instead |
Seems to work as of 6e05a33 as you can see https://github.com/ollegkz/olle.coffee/actions/runs/7423744689/job/20201840905 but the url is no longer printed out in the deploy complete step 😮 Compare https://github.com/ollegkz/olle.coffee/actions/runs/7423744689/job/20201840905 complete job with https://github.com/ollegkz/olle.coffee/actions/runs/7400679346/job/20134828466 :suprised_pikachu: |
Thanks @ollegkz! I forked your repo so I can test changes directly against it. I think it's bun-specific. |
Any luck on merging this @natemoo-re? 🥇 |
Works for root deployment. To summarize then, the "site" param in
But I hope we can simplify the docs a bit once this is merged. |
Hmm, I just noticed that actions/configure-pages@v3 uses node16 and actions/configure-pages@v4 uses node20 :) |
I'm converting this to a draft since I haven't had time to finish this up! I still think this is a better solution that what we have currently, but I'm hesitant about spawning the If anyone else wants to pick this up, please do. Otherwise I will try to circle back to this in the future. |
After looking at how we recommend this action is used, it turns out we can do a bit more to make it simple for people to use. This would be a great v2 for this action.
Based on https://github.com/actions/configure-pages, we can automatically infer the correct
--site
and--base
flags for Astro to use when building. This eliminates the main gotcha with our current setup (that you almost certainly need to update your config with these values).This also automatically uses
actions/checkout@v4
to pull your repo andactions/deploy-pages@v2
to deploy your site to GitHub Pages. These changes mean that our recommended setup is greatly simplified.Instead of running
npm run build
, we now run theastro
CLI directly. Honestly this is the change I'm most hesitant about, because some folks might want CI to fail ifastro-check
fails or use pre/post-build scripts. This change would skip those and just doastro build
. Open to feedback!