Files
NomadBackup/.github/workflows/backup.yml
sstent 57ecf35195
Some checks failed
Infrastructure Backup / backup (push) Failing after 10s
sync
2025-11-21 13:36:35 -08:00

62 lines
1.7 KiB
YAML

name: Infrastructure Backup
on:
schedule:
# Run daily at 2 AM UTC (6 PM PST)
- cron: '0 2 * * *'
workflow_dispatch: # Allow manual triggering
jobs:
backup:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# Fetch all history so we can properly commit changes
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests
- name: Run Nomad backup
env:
NOMAD_ADDR: ${{ secrets.NOMAD_ADDR }}
NOMAD_TOKEN: ${{ secrets.NOMAD_TOKEN }}
run: |
python backup.py --output nomad_backup
- name: Run Consul backup
env:
CONSUL_HTTP_ADDR: ${{ secrets.CONSUL_HTTP_ADDR }}
CONSUL_HTTP_TOKEN: ${{ secrets.CONSUL_HTTP_TOKEN }}
run: |
python consul_backup.py --output consul_backup
- name: Check for changes
id: check_changes
run: |
git add nomad_backup/ consul_backup/
if git diff --staged --quiet; then
echo "changes=false" >> $GITHUB_OUTPUT
echo "No changes to commit"
else
echo "changes=true" >> $GITHUB_OUTPUT
echo "Changes detected, will commit"
fi
- name: Commit and push changes
if: steps.check_changes.outputs.changes == 'true'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -m "chore: backup infrastructure configurations [skip ci]"
git push