Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Snowflake cleanup #130

Merged
merged 2 commits into from
Jul 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/cleanup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:

snowflake-delete:
name: Delete Snowflake development environment
if: ${{ github.ref_name != 'main' && github.ref_name != 'staging' }}
philerooski marked this conversation as resolved.
Show resolved Hide resolved
if: ${{ github.event.ref != 'main' && github.event.ref != 'staging' }}
runs-on: ubuntu-latest
env:
PRIVATE_KEY_PASSPHRASE: ${{ secrets.SNOWFLAKE_PRIVATE_KEY_PASSPHRASE }}
Expand Down Expand Up @@ -52,7 +52,7 @@ jobs:
run: |
snow sql \
-q "
SET safe_environment_identifier = (SELECT REPLACE('$GITHUB_REF_NAME', '-', '_'));
SET safe_environment_identifier = (SELECT REPLACE('${{ github.event.ref }}', '-', '_'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't looked very closely, but we will want to be careful to not bring down main / dev databases and tables. Only for feature branches in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That could only happen if we delete the main branch, which would be catastrophic in other ways. But no need to compound the damage. I added a conditional on this job just in case.

philerooski marked this conversation as resolved.
Show resolved Hide resolved
SET database_identifier = CONCAT('recover_', \$safe_environment_identifier);
DROP DATABASE IDENTIFIER(\$database_identifier);
"
Expand Down
Loading