Skip to content

Commit a64f9cb

Browse files
committed
Use backups secrets
1 parent 9d35b86 commit a64f9cb

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

.github/workflows/preview-web-up.yaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ on:
99
description: web-* branch to preview
1010
required: true
1111
backup_url:
12-
description: apidb backup .sql.gz URL to load
13-
required: true
12+
description: apidb backup URL (.sql or .sql.gz); blank = PREVIEW_BACKUP_URL secret
13+
required: false
1414
push:
1515
branches:
1616
- 'web-*'
@@ -154,8 +154,9 @@ jobs:
154154
BACKUP_URL: ${{ github.event.inputs.backup_url || secrets.PREVIEW_BACKUP_URL }}
155155
run: |
156156
if [ -z "$BACKUP_URL" ]; then
157-
echo "::error::no backup_url input and PREVIEW_BACKUP_URL secret is empty"; exit 1
157+
echo "::error::set the PREVIEW_BACKUP_URL secret (or pass backup_url on dispatch)"; exit 1
158158
fi
159+
echo "backup: $BACKUP_URL"
159160
WEB_IMAGE="$(helm -n "$NS" get values "$RELEASE" -a -o json \
160161
| python3 -c 'import sys,json;w=json.load(sys.stdin)["osm-seed"]["web"]["image"];print(f"{w[\"name\"]}:{w[\"tag\"]}")')"
161162
echo "restore image: $WEB_IMAGE"
@@ -186,8 +187,11 @@ jobs:
186187
echo "waiting for db..."
187188
until pg_isready -h $RELEASE-db -p 5432; do sleep 2; done
188189
echo "downloading + restoring backup..."
189-
curl -fsSL "\$BACKUP_URL" | gunzip -c \
190-
| psql -h $RELEASE-db -U postgres -d openhistoricalmap
190+
# handle both plain .sql and gzipped .sql.gz
191+
case "\$BACKUP_URL" in
192+
*.gz) curl -fsSL "\$BACKUP_URL" | gunzip -c | psql -h $RELEASE-db -U postgres -d openhistoricalmap ;;
193+
*) curl -fsSL "\$BACKUP_URL" | psql -h $RELEASE-db -U postgres -d openhistoricalmap ;;
194+
esac
191195
echo "restore done"
192196
EOF
193197
kubectl -n "$NS" wait --for=condition=complete --timeout=30m job/$RELEASE-restore \

values.k3s.preview.template.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ osm-seed:
5454
OPENSTREETMAP_AUTH_SECRET: "none"
5555
WIKIPEDIA_AUTH_ID: "none"
5656
WIKIPEDIA_AUTH_SECRET: "none"
57-
BACKUP_FILE_URL: "https://osmseed-dev.s3.amazonaws.com/backup_test_ohm.sql"
5857
resources:
5958
enabled: false
6059
autoscaling:

0 commit comments

Comments
 (0)