61 lines
2.1 KiB
YAML
61 lines
2.1 KiB
YAML
name: Export staging 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 ISAC data and uploaded icons
|
|
env:
|
|
CONFIGURED_DEPLOY_PATH: ${{ vars.STAGE_DEPLOY_PATH }}
|
|
run: |
|
|
set -eu
|
|
deployment_path="${CONFIGURED_DEPLOY_PATH:-/opt/shd-build-stage}"
|
|
compose_file="$deployment_path/compose.staging.yml"
|
|
deploy_environment="$deployment_path/.env.deploy"
|
|
compose() {
|
|
docker compose --env-file "$deploy_environment" -f "$compose_file" "$@"
|
|
}
|
|
snapshot_name="isac-stage-${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 staging 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-stage.json"
|
|
compose run --rm --no-deps app rm -f "$volume_snapshot"
|
|
remove_volume_snapshot=false
|
|
|
|
- name: Publish ISAC snapshot
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: shd-stage-isac-data
|
|
path: isac-stage.json
|
|
retention-days: 14
|