Daily Portal Status Check #46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Daily Portal Status Check | |
| on: | |
| schedule: | |
| # 04:30 UTC daily | |
| - cron: '30 4 * * *' | |
| workflow_dispatch: # manual trigger | |
| permissions: | |
| contents: write | |
| jobs: | |
| check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Check portals | |
| env: | |
| JAKARTA_SSH_KEY: ${{ secrets.JAKARTA_SSH_KEY }} | |
| run: | | |
| # Set up Jakarta SSH if key is available | |
| if [ -n "$JAKARTA_SSH_KEY" ]; then | |
| mkdir -p ~/.ssh | |
| echo "$JAKARTA_SSH_KEY" > ~/.ssh/jakarta | |
| chmod 600 ~/.ssh/jakarta | |
| echo "Host jakarta" >> ~/.ssh/config | |
| echo " HostName 117.53.46.31" >> ~/.ssh/config | |
| echo " User polybot" >> ~/.ssh/config | |
| echo " IdentityFile ~/.ssh/jakarta" >> ~/.ssh/config | |
| echo " StrictHostKeyChecking no" >> ~/.ssh/config | |
| echo " ConnectTimeout 5" >> ~/.ssh/config | |
| fi | |
| python3 status/check.py | |
| - name: Build history.json | |
| run: | | |
| python3 -c " | |
| import json, os | |
| data_dir = 'status/data' | |
| with open(os.path.join(data_dir, 'index.json')) as f: | |
| days = json.load(f) | |
| history = {} | |
| for day in days: | |
| fp = os.path.join(data_dir, f'{day}.json') | |
| if os.path.exists(fp): | |
| with open(fp) as f: | |
| history[day] = json.load(f) | |
| with open(os.path.join(data_dir, 'history.json'), 'w') as f: | |
| json.dump(history, f) | |
| print(f'history.json: {len(history)} days') | |
| " | |
| - name: Commit results | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add status/data/ | |
| if git diff --cached --quiet; then | |
| echo "No changes" | |
| else | |
| DATE=$(date -u +%Y-%m-%d) | |
| git commit -m "status: daily check ${DATE}" | |
| git pull --rebase origin main | |
| git push | |
| fi | |
| - name: Deploy to Cloudflare Pages | |
| uses: cloudflare/wrangler-action@v3 | |
| with: | |
| apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| command: pages deploy status --project-name gov-portal-status --branch main |