jrencz
jrencz
CDCloudflare Developers
Created by jrencz on 4/20/2024 in #pages-help
cloudflare/pages-action: any way to know CF_PAGES_URL ahead of running the action?
Hi, I have a setup that's making use of the CF_PAGES_URL as described in docs In my build I'm getting the id out of it and I put it somewhere in assets. It's important to the setup because what comes out of the build is not served directly from the *.pages.dev, but instead the root of *.pages.dev is served as a path of some domain. id becomes part of path like this:
/some-ns/:id/file.ext
/some-ns/:id/file.ext
I have a bunch of previews - ad-hoc previews on push to all branches (e.g. feature and fixes). - several long-living branches, representing a shared testing envs. In my reverse proxy I'm using those known aliases to express where the "things" are Then - and that's why I really need the id to be known ahead of time - if my statics (ES modules) load something, I don't want them to load from alias. Things on it might have already been replaced. I make them load from
/some-ns/:id/thing.es.js
/some-ns/:id/thing.es.js
(as mentioned). This way those are essentially permalink. That's what I'm after. The address to the entrypoint, which I named autoloader.js doesn't have :id in it. It's
/some-ns/autoloader.js
/some-ns/autoloader.js
This setup works well - no problems. But that's at a cost of actually having several long-living branches in repo origin. And that bugs me. Or, rather, it confuses other guys in my team. They sometimes ask if we couldn't get rid of them (they're not that much into the "git-ops" concept as I am - I'm not blaming them, I'm stating the fact). I'm looking for alternative, and I know there's cloudflare/pages-action. I even use it in some other setups that don't depend on id. And it can be given the branch. YEAH! I've got it!… but… there's this id thing. So, having all that written down: is there maybe a way to get the id (or the whole url, as in automatic build) somehow in GHA but not as action Output, or if I'm dependent on id I'm forced to use automatic deployments?
2 replies