R
Railway•13mo ago
donutmuncha

Force build via Railway CLI

I am using Github Actions to force a build of my Astro frontend if content in the CMS is updated. Here are my steps:
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "14"
- name: Install Railway CLI
run: npm install -g railway
- name: Login to Railway
run: railway login --browserless
env:
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
- name: Trigger Railway Build for Astro Frontend
run: railway up -e staging --service astro_frontend
env:
RAILWAY_PROJECT_ID: ${{ secrets.RAILWAY_PROJECT_ID }}
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "14"
- name: Install Railway CLI
run: npm install -g railway
- name: Login to Railway
run: railway login --browserless
env:
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
- name: Trigger Railway Build for Astro Frontend
run: railway up -e staging --service astro_frontend
env:
RAILWAY_PROJECT_ID: ${{ secrets.RAILWAY_PROJECT_ID }}
When I run railway up -e staging --service astro_frontend directly from my CLI, it works. However Railway skips the build if no files have physically changed. How can I force the build to complete?
14 Replies
Brody
Brody•13mo ago
do you have any watch paths set?
donutmuncha
donutmunchaOP•13mo ago
yes
donutmuncha
donutmunchaOP•13mo ago
No description
Brody
Brody•13mo ago
well if nothing changes of course railway isn't gonna rebuild, just write a random file into that folder in your action
donutmuncha
donutmunchaOP•13mo ago
How about if I remove the watch path?
Brody
Brody•13mo ago
that works too, but then a build would be triggered if you made changes to another app within the repo
donutmuncha
donutmunchaOP•13mo ago
I was thinking that I could move them all into github actions rather than rely opon Railway to trigger the builds. e.g - push to repo > github action (create custom watch) > railway up -e staging --service astro_frontend I think the ability to override/force build would be a handy addition to the CLI. I'll create a ticket for it thanks for helping, as always Brody
Brody
Brody•13mo ago
that would not be a simple addition to the cli
donutmuncha
donutmunchaOP•13mo ago
I can always ask!
Brody
Brody•13mo ago
fair enough
donutmuncha
donutmunchaOP•13mo ago
awesome, removing the watch for my frontend worked perfectly. Thanks!
Brody
Brody•13mo ago
no problem 🙂
donutmuncha
donutmunchaOP•13mo ago
I took your advice and removed all the complexity. Added the watch path back. (Not going to ask for CLI amends 🙂 ) Instead I amend the README with the last deployed date.
name: Payload update
on:
repository_dispatch:
types:
- payload_update

jobs:
update-deployment-time:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v2

- name: Update deployment time
run: |
# Define the date format
DATE_FORMAT="$(date -u +'%a %b %d %Y %H:%M:%S GMT+0000 (Coordinated Universal Time)')"

# Replace the line in the markdown file
sed -i "s/Last deployed:.*/Last deployed: $DATE_FORMAT/" apps/web/README.md

- name: Commit and push
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add apps/web/README.md
git commit -m "chore: Github Action - redeployed frontend"
git push
name: Payload update
on:
repository_dispatch:
types:
- payload_update

jobs:
update-deployment-time:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v2

- name: Update deployment time
run: |
# Define the date format
DATE_FORMAT="$(date -u +'%a %b %d %Y %H:%M:%S GMT+0000 (Coordinated Universal Time)')"

# Replace the line in the markdown file
sed -i "s/Last deployed:.*/Last deployed: $DATE_FORMAT/" apps/web/README.md

- name: Commit and push
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add apps/web/README.md
git commit -m "chore: Github Action - redeployed frontend"
git push
Brody
Brody•13mo ago
okay now that's even better than creating a random file
Want results from more Discord servers?
Add your server