Invalidate Cloudfront after deploy completes

Hey everyone, quick questions I was looking through the documentation and Im wondering how I can run a command after a build completes a successful deploy wih railway example -> aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths '/*'
21 Replies
Percy
Percy2mo ago
Project ID: N/A
Aaron Janes
Aaron Janes2mo ago
N/A
Brody
Brody2mo ago
so first, how do you currently have your service setup to deploy to railway? github action? github source?
Aaron Janes
Aaron Janes2mo ago
just as a github source
Brody
Brody2mo ago
could you include a pre-run shell script with that command? then update your start command to ./pre-run.sh && <original start command> as long as you use a readiness type health check your deployment would not be switched in until its ready to handle requests
Aaron Janes
Aaron Janes2mo ago
hmmm, so for context I use alot of git hub actions , cloudformation etc for work . I only used the git hub source as I was just testing out railway. Can I do all this with git hub actions on railway ?
Brody
Brody2mo ago
at this moment, nope. it's currently broken, but otherwise you would use railway up in an action with the --ci flag, with that flag set it will wait for the deployment to either succeed or fail and exit with the applicable exit code, then you would run your aws command in the action as long as the deployment succeed. but that's currently broken so pre-run script is the best I can think of.
Aaron Janes
Aaron Janes2mo ago
Okay interesting thanks for the insight
Brody
Brody2mo ago
of course the drawback of the pre-run script is now you need to bundle the aws cli with your image
Aaron Janes
Aaron Janes2mo ago
Yea, i was hoping for a simple solution instead of building a docker image and packing everything. Which i suppose if i have to do then I would just stuff it back into aws
Brody
Brody2mo ago
yeah for now the pre-run script is the best way I can think of
Aaron Janes
Aaron Janes2mo ago
Do you have a gist or simlar of what your envisioning ?
Brody
Brody2mo ago
do you currently use a dockerfile or nixpacks?
Aaron Janes
Aaron Janes2mo ago
I was just setting a basic next js app with strapi cms. and uses the templats I found on railway I believe they use nixpacks
Brody
Brody2mo ago
I think you can get the aws cli as a nix package, but I actually just thought of something that has a slim chance to get --ci to work in an action, let me do some testing
Aaron Janes
Aaron Janes2mo ago
nice
Brody
Brody2mo ago
I assume you're familiar with how to get the aws cli available in a GitHub action?
Aaron Janes
Aaron Janes2mo ago
uses: chrislennon/action-aws-cli@v1.1 yup
Brody
Brody2mo ago
not working how i had hoped, but ive ran out of time for today
Aaron Janes
Aaron Janes2mo ago
I appreciate the effort I can try to run some bash commands in an action now to see how things pan out
Duchess
Duchess4w ago
New reply sent from Help Station thread:
Can you let me know how you connected CloudFront inside the railway server?
You're seeing this because this thread has been automatically linked to the Help Station thread.