FossilRepo
| afe42d0… | ragelink | 1 | #!/bin/bash |
| 7e1aaf6… | ragelink | 2 | # deploy.sh — push local changes to fossilrepo.io |
| 7e1aaf6… | ragelink | 3 | # |
| 7e1aaf6… | ragelink | 4 | # Flow: |
| 7e1aaf6… | ragelink | 5 | # 1. Fossil commit + push (writes to /data/repos/fossilrepo.fossil on server) |
| 7e1aaf6… | ragelink | 6 | # 2. SSM runs fossilrepo-deploy (fossil update + pip + migrate + collectstatic + restart) |
| 7e1aaf6… | ragelink | 7 | # |
| 7e1aaf6… | ragelink | 8 | # Requires .env.deploy with FOSSIL_REMOTE_URL and EC2_INSTANCE_ID |
| afe42d0… | ragelink | 9 | |
| afe42d0… | ragelink | 10 | set -euo pipefail |
| afe42d0… | ragelink | 11 | |
| 45192ef… | ragelink | 12 | if [[ ! -f .env.deploy ]]; then |
| 45192ef… | ragelink | 13 | echo "Missing .env.deploy -- copy .env.deploy.example and fill in your values" |
| 45192ef… | ragelink | 14 | exit 1 |
| 45192ef… | ragelink | 15 | fi |
| 45192ef… | ragelink | 16 | |
| 45192ef… | ragelink | 17 | source .env.deploy |
| afe42d0… | ragelink | 18 | |
| afe42d0… | ragelink | 19 | MSG="${1:-Deploy $(date +%Y-%m-%d-%H%M)}" |
| afe42d0… | ragelink | 20 | |
| afe42d0… | ragelink | 21 | echo "=== Fossil commit ===" |
| afe42d0… | ragelink | 22 | fossil addremove 2>/dev/null || true |
| 7e1aaf6… | ragelink | 23 | fossil commit --no-warnings -m "$MSG" 2>&1 || echo "Nothing to commit" |
| 45192ef… | ragelink | 24 | |
| 45192ef… | ragelink | 25 | echo "=== Fossil push ===" |
| 45192ef… | ragelink | 26 | fossil push "$FOSSIL_REMOTE_URL" |
| 45192ef… | ragelink | 27 | |
| 7e1aaf6… | ragelink | 28 | echo "=== Deploy to server ===" |
| 45192ef… | ragelink | 29 | AWS_PROFILE=fossiladmin aws ssm send-command \ |
| 45192ef… | ragelink | 30 | --instance-ids "$EC2_INSTANCE_ID" \ |
| 45192ef… | ragelink | 31 | --document-name "AWS-RunShellScript" \ |
| 7e1aaf6… | ragelink | 32 | --timeout-seconds 120 \ |
| 7e1aaf6… | ragelink | 33 | --parameters '{"commands":["export HOME=/root && fossilrepo-deploy 2>&1"]}' \ |
| 7e1aaf6… | ragelink | 34 | --region "${AWS_REGION:-us-west-2}" \ |
| afe42d0… | ragelink | 35 | --query "Command.CommandId" \ |
| afe42d0… | ragelink | 36 | --output text |
| afe42d0… | ragelink | 37 | |
| 7e1aaf6… | ragelink | 38 | echo "=== Deployed ===" |