Skip to content

Check and Deploy

Check and Deploy #5189

name: Check and Deploy
on:
schedule:
- cron: "*/30 * * * *" # runs every 30 minutes
jobs:
check_deploy:
runs-on: ubuntu-latest
steps:
# 1. Checkout the repository.
- name: Checkout repository
uses: actions/checkout@v3
# 2. Setup Node.js environment.
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
# 3. Install Puppeteer dependencies (removed libasound2 to avoid install errors).
- name: Install Puppeteer dependencies
run: |
sudo apt-get update
sudo apt-get install -y libnss3 libatk-bridge2.0-0 libx11-xcb1 libxcomposite1 libxrandr2
# 4. Use Puppeteer to check if the website shows the update text.
- name: Check website for update text with Puppeteer
id: check
run: |
yarn add puppeteer
node -e "const puppeteer = require('puppeteer'); (async () => {
const browser = await puppeteer.launch({ args: ['--no-sandbox'] });
const page = await browser.newPage();
await page.goto('https://www.validityops.com', { waitUntil: 'networkidle2' });
const text = await page.evaluate(() => document.body.innerText);
const found = text.includes('Namadillo is running an outdated version');
console.log('Found text:', found, text);
const fs = require('fs');
fs.appendFileSync(process.env.GITHUB_OUTPUT, 'found=' + (found ? 'true' : 'false') + '\n');
await browser.close();
})();"
# 5. If the text is found, add upstream remote and merge its main branch.
- name: Merge upstream changes if update text found
if: steps.check.outputs.found == 'true'
run: |
git remote add upstream https://github.com/anoma/namada-interface.git || true
git fetch upstream
git checkout main
git merge upstream/main --no-edit
# 6. Build the Namadillo app with updated commands.
- name: Build Namadillo app
if: steps.check.outputs.found == 'true'
run: |
cd apps/namadillo
yarn
yarn wasm:build
yarn wasm:build:dev
yarn build
# 7. Add the rewrites file in the build output (dist).
- name: Add rewrites file
if: steps.check.outputs.found == 'true'
run: |
cd apps/namadillo/dist
echo '{ "rewrites": [ { "source": "/(.*)", "destination": "/index.html" } ] }' > rewrites.json
# 8. Commit and push changes to main.
- name: Commit and push changes
if: steps.check.outputs.found == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Auto-update: merge upstream changes and add rewrites" || echo "No changes to commit"
git push origin main
# 9. Deploy using Vercel by piping in the required responses.
- name: Deploy with Vercel
if: steps.check.outputs.found == 'true'
run: |
npm install -g vercel
# Simulate the four responses:
# 1) "y" + Enter
# 2) Enter
# 3) "y" + Enter
# 4) "namada" + Enter
printf "y\n\ny\nnamada\n" | vercel --prod