-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial version of migration trigger workflow
This workflow can be used to trigger migration workflows in other repositories. Currently, it has a single job that triggers ConsDB migrations in the lsst-dm/consdb repo.
- Loading branch information
1 parent
8aad214
commit f7e6172
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Trigger Database Migrations | ||
|
||
on: | ||
pull_request: | ||
types: [closed] | ||
|
||
jobs: | ||
migrate-cdb: | ||
runs-on: ubuntu-latest | ||
if: github.event.pull_request.merged == true # Only trigger on merged PRs | ||
|
||
steps: | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
ref: ${{ github.head_ref }} | ||
|
||
- name: Fetch main branch | ||
run: git fetch origin main | ||
|
||
- name: Set relative path to schema directory | ||
run: | | ||
echo "SCHEMA_DIR=python/lsst/sdm_schemas/schemas" >> $GITHUB_ENV | ||
- name: Check for changed cdb schemas # TODO: Use 'felis diff -c alembic' when available (DM-46130) | ||
run: | | ||
CHANGED_FILES=$(git diff --name-only origin/main..HEAD -- ${{ env.SCHEMA_DIR }}) | ||
if [ -z "$CHANGED_FILES" ]; then | ||
echo "No schema files changed" | ||
exit 0 | ||
fi | ||
CHANGED_FILES=$(echo $CHANGED_FILES | xargs basename | grep -E '^cdb_.*\.yaml$') | ||
if [ -z "$CHANGED_FILES" ]; then | ||
echo "No cdb schema files changed" | ||
exit 0 | ||
fi | ||
echo "Changed cdb schema files: $CHANGED_FILES" | ||
- name: Print branch name and commit SHA | ||
run: | | ||
echo "Branch name: ${{ github.head_ref }}" | ||
echo "Commit SHA: ${{ github.event.pull_request.merge_commit_sha }}" | ||
- name: Trigger migration workflow in consdb repository | ||
run: | | ||
curl -X POST \ | ||
-H "Authorization: token ${{ secrets.REPO_DISPATCH_TOKEN }}" \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
https://api.github.com/repos/lsst-dm/consdb/dispatches \ | ||
-d '{ | ||
"event_type": "migration", | ||
"client_payload": { | ||
"branch_name": "${{ github.head_ref }}", | ||
"commit_sha": "${{ github.event.pull_request.merge_commit_sha }}" | ||
} | ||
}' |