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

Automate migrations #132

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
40 changes: 40 additions & 0 deletions .github/workflows/staging-migrations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Apply staging migrations on PR when there are changes in the migrations folder

on:
pull_request:
types: [opened, synchronize]

jobs:
check-folder-changes:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Check for changes in specific folder
id: check_changes
run: |
if git diff --name-only origin/main...HEAD | grep -q '^src/specific-folder/'; then
echo "changes=true" >> $GITHUB_ENV
else
echo "changes=false" >> $GITHUB_ENV
fi

apply-staging:
needs: check-folder-changes
if: env.changes == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Install dependencies
run: npm install

- name: Run TypeScript script
run: npm run migrations:apply-staging
16 changes: 8 additions & 8 deletions config/dato/instances.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ module.exports.instances = [
name: "nl2120",
key: process.env.DATO_API_KEY_NL2120,
},
{
name: "openearth-data-viewer",
key: process.env.DATO_API_KEY_OPENEARTH_DATA_VIEWER,
},
{
name: "openearth-rws-viewer",
key: process.env.DATO_API_KEY_OPENEARTH_RWS_VIEWER,
},
// {
// name: "openearth-data-viewer",
// key: process.env.DATO_API_KEY_OPENEARTH_DATA_VIEWER,
// },
// {
// name: "openearth-rws-viewer",
// key: process.env.DATO_API_KEY_OPENEARTH_RWS_VIEWER,
// },
];
2 changes: 2 additions & 0 deletions scripts/dato/apply-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ async function main() {

const client = new DatoClient(instance.key);

await client.runCommand(["maintenance:on"]);

const existingEnvironments = await client.listEnvironments();

const stagingExists = existingEnvironments?.some(
Expand Down