Invalidate Cloudfront after deploy completes

AnonymousTRIAL

a year ago

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 '/*'

1 Replies

AnonymousTRIAL

a year ago

N/A


a year ago

so first, how do you currently have your service setup to deploy to railway? github action? github source?


AnonymousTRIAL

a year ago

just as a github source


a year ago

could you include a pre-run shell script with that command? then update your start command to ./[pre-run.sh](pre-run.sh) &&


a year ago

as long as you use a readiness type health check your deployment would not be switched in until its ready to handle requests


AnonymousTRIAL

a year 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 ?


a year 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.


AnonymousTRIAL

a year ago

Okay interesting thanks for the insight


a year ago

of course the drawback of the pre-run script is now you need to bundle the aws cli with your image


AnonymousTRIAL

a year 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


a year ago

yeah for now the pre-run script is the best way I can think of


AnonymousTRIAL

a year ago

Do you have a gist or simlar of what your envisioning ?


a year ago

do you currently use a dockerfile or nixpacks?


AnonymousTRIAL

a year ago

I was just setting a basic next js app with strapi cms. and uses the templats I found on railway


AnonymousTRIAL

a year ago

I believe they use nixpacks


a year 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


AnonymousTRIAL

a year ago

nice


a year ago

I assume you're familiar with how to get the aws cli available in a GitHub action?


AnonymousTRIAL

a year ago

uses: chrislennon/action-aws-cli@v1.1


AnonymousTRIAL

a year ago

yup


a year ago

not working how i had hoped, but ive ran out of time for today

1242143002932154600


AnonymousTRIAL

a year ago

I appreciate the effore


AnonymousTRIAL

a year ago

I can try to run some bash commands in an action now to see how things pan out


fmchistiPRO

a year ago

Can you let me know how you connected CloudFront inside the railway server?