diff --git a/.github/workflows/staging-migrations.yaml b/.github/workflows/staging-migrations.yaml new file mode 100644 index 00000000..2d761c54 --- /dev/null +++ b/.github/workflows/staging-migrations.yaml @@ -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 diff --git a/config/dato/instances.js b/config/dato/instances.js index 79d5a7d8..b150893f 100644 --- a/config/dato/instances.js +++ b/config/dato/instances.js @@ -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, + // }, ]; diff --git a/scripts/dato/apply-main.ts b/scripts/dato/apply-main.ts index ff450393..35b19357 100644 --- a/scripts/dato/apply-main.ts +++ b/scripts/dato/apply-main.ts @@ -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(