Files
shd.build/.gitea/workflows/export-production-isac-data.yml
T
jb 25d9241b51
Validate and deploy production / validate (push) Canceled after 0s
Validate and deploy production / deploy (push) Canceled after 0s
Validate and deploy staging / validate (push) Failing after 22s
Validate and deploy staging / deploy (push) Skipped
feat: migrate secrets to Infisical
2026-08-02 01:19:41 -04:00

61 lines
2.1 KiB
YAML

name: Export production ISAC data
on:
workflow_dispatch:
concurrency:
group: shd-build-host-maintenance
cancel-in-progress: false
jobs:
export:
runs-on: stage-deploy
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Export canonical production ISAC data and uploaded icons
env:
CONFIGURED_DEPLOY_PATH: ${{ vars.PRODUCTION_DEPLOY_PATH }}
run: |
set -eu
deployment_path="${CONFIGURED_DEPLOY_PATH:-/opt/shd-build-production}"
compose_file="$deployment_path/compose.production.yml"
deploy_environment="$deployment_path/.env.deploy"
compose() {
docker compose --env-file "$deploy_environment" -f "$compose_file" "$@"
}
snapshot_name="isac-production-${GITHUB_RUN_ID}.json"
volume_snapshot="/app/data/exports/$snapshot_name"
remove_volume_snapshot=false
cleanup() {
exit_status=$?
trap - EXIT
if [ "$remove_volume_snapshot" = true ]; then
compose run --rm --no-deps app rm -f "$volume_snapshot" || true
fi
if ! compose up -d --no-build app scheduler; then
if [ "$exit_status" -eq 0 ]; then exit_status=1; fi
fi
exit "$exit_status"
}
trap cleanup EXIT
compose stop scheduler app
app_container="$(compose ps --all --quiet app)"
if [ -z "$app_container" ]; then
echo "The stopped production app container could not be found." >&2
exit 1
fi
remove_volume_snapshot=true
compose run --rm --no-deps app node scripts/isac-data-export.mjs "$volume_snapshot"
docker cp "$app_container:$volume_snapshot" "$GITHUB_WORKSPACE/isac-production.json"
compose run --rm --no-deps app rm -f "$volume_snapshot"
remove_volume_snapshot=false
- name: Publish production ISAC snapshot
uses: actions/upload-artifact@v3
with:
name: shd-production-isac-data
path: isac-production.json
retention-days: 14