From d0f479ffc025189ee434376fb1a277b33b8a2920 Mon Sep 17 00:00:00 2001 From: John Craft Date: Tue, 24 Oct 2023 09:32:54 -0700 Subject: [PATCH] Comment on success or failure of migration --- .github/workflows/test-migration.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-migration.yml b/.github/workflows/test-migration.yml index ad6a41a..c941e56 100644 --- a/.github/workflows/test-migration.yml +++ b/.github/workflows/test-migration.yml @@ -66,14 +66,19 @@ jobs: - name: Run Sequelize migrations run: | cd ./users-api/src - npx sequelize-cli db:migrate + if npx sequelize-cli db:migrate; then + echo "PR_COMMENT=:white_check_mark: Database migration succeeded!" >> $GITHUB_ENV + else + echo "PR_COMMENT=:x: Database migration failed." >> $GITHUB_ENV + fi + continue-on-error: true - name: Cleanup run: docker stop $DB_HOST - - name: Post a comment to PR + - name: Comment on success of migration run: | - PR_COMMENT="This PR contains database migrations." + PR_COMMENT=":x: Database migration failed" # Post the comment to the PR curl \ @@ -81,4 +86,4 @@ jobs: -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ -H "Accept: application/vnd.github.v3+json" \ https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \ - -d "{\"body\":\"$PR_COMMENT\"}" + -d "{\"body\":\"env.PR_COMMENT\"}"