Skip to content

Commit 505194d

Browse files
committed
Moving scripts to .pscale/cli-helper-scripts
Delete ps-env-test-ps-create.sh Adding script file to git ignore Use environment URL
1 parent 76d6d35 commit 505194d

30 files changed

+68
-41
lines changed

.github/workflows/add-operation-column-and-index.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name: 02 - Add Operation Column & Index
33
on:
44
workflow_dispatch
55

6+
env:
7+
pscale_base_directory: .pscale
8+
69
jobs:
710

811
add-operation-column-and-index:
@@ -21,6 +24,7 @@ jobs:
2124
ORG_NAME: ${{secrets.ORG_NAME}}
2225
DB_NAME: ${{secrets.DB_NAME}}
2326
GITHUB_USER: ${{github.actor}}
27+
working-directory: ${{env.pscale_base_directory}}/cli-helper-scripts/
2428
run: ./add-operation-column-and-index.sh
2529
- name: Please check out deployment request and branch connection string from step above
2630
run: |

.github/workflows/create-database.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name: 01 - Create Database
33
on:
44
workflow_dispatch
55

6+
env:
7+
pscale_base_directory: .pscale
8+
69
jobs:
710

811
create-database:
@@ -20,6 +23,7 @@ jobs:
2023
ORG_NAME: ${{secrets.ORG_NAME}}
2124
DB_NAME: ${{secrets.DB_NAME}}
2225
GITHUB_USER: ${{github.actor}}
26+
working-directory: ${{env.pscale_base_directory}}/cli-helper-scripts/
2327
run: ./create-database.sh
2428
- name: Please set MY_DB_URL with instructions from step above
2529
run: |

.github/workflows/create-db-branch-and-pr-dr.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: Create branch/PR for schema change
22

3+
env:
4+
pscale_base_directory: .pscale
5+
36
on:
47
workflow_dispatch:
58
inputs:
@@ -61,6 +64,7 @@ jobs:
6164
GITHUB_USER: ${{github.actor}}
6265
DDL_STATEMENTS: ${{ steps.validate_params.outputs.ddl_statements }}
6366
BRANCH_NAME: ${{ steps.validate_params.outputs.branch_name }}
67+
working-directory: ${{env.pscale_base_directory}}/cli-helper-scripts/
6468
run: |
6569
./create-db-branch-dr-and-connection.sh "$BRANCH_NAME" "$DDL_STATEMENTS"
6670
@@ -72,10 +76,11 @@ jobs:
7276
DEPLOY_REQUEST_NUMBER: ${{ steps.create-db-branch-and-dr.outputs.DEPLOY_REQUEST_NUMBER }}
7377
DEPLOY_REQUEST_URL: ${{ steps.create-db-branch-and-dr.outputs.DEPLOY_REQUEST_URL }}
7478
BRANCH_URL: ${{ steps.create-db-branch-and-dr.outputs.BRANCH_URL }}
79+
working-directory: ${{env.pscale_base_directory}}/cli-helper-scripts/
7580
run: |
76-
mkdir -p .pscale
77-
envsubst < ps-env-template.sh > .pscale/ps-env-${BRANCH_NAME}.sh
78-
chmod a+x .pscale/ps-env-${BRANCH_NAME}.sh
81+
mkdir -p ../env/
82+
envsubst < ps-env-template.sh > ../env/ps-env-${BRANCH_NAME}.sh
83+
chmod a+x ../env/ps-env-${BRANCH_NAME}.sh
7984
8085
8186
- name: Create corresponding Git branch and Pull Request

.github/workflows/issue-ops-ps-commands.yml

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
issue_comment:
55
types: [created]
66

7+
env:
8+
pscale_base_directory: .pscale
9+
10+
711
jobs:
812
prechecks:
913
name: Permission pre-check
@@ -112,7 +116,8 @@ jobs:
112116
id: get-ps-env
113117
env:
114118
REF: ${{ needs.prechecks.outputs.ref }}
115-
run: .pscale/ps-env-${REF}.sh
119+
working-directory: ${{env.pscale_base_directory}}
120+
run: env/ps-env-${REF}.sh
116121

117122
- name: Acknowledge /ps-merge request with context
118123
id: acknowledge
@@ -188,9 +193,9 @@ jobs:
188193
PLANETSCALE_SERVICE_TOKEN: ${{secrets.PLANETSCALE_SERVICE_TOKEN}}
189194
GITHUB_USER: ${{github.actor}}
190195
REF: ${{ needs.prechecks.outputs.ref }}
191-
196+
working-directory: ${{env.pscale_base_directory}}/cli-helper-scripts/
192197
run: |
193-
. .pscale/ps-env-${REF}.sh && ./merge-deploy-request.sh $DEPLOY_REQUEST_NUMBER
198+
. ../env/ps-env-${REF}.sh && ./merge-deploy-request.sh $DEPLOY_REQUEST_NUMBER
194199
195200
- name: Schema change merge succeeded
196201
id: merging-succeeded
@@ -215,7 +220,7 @@ jobs:
215220
deployment_id: deployment_id,
216221
state: 'success',
217222
description: 'Schema changes merged successfully from branch ' + BRANCH_NAME + ' :tada:',
218-
target_url: DEPLOY_REQUEST_URL,
223+
environment_url: DEPLOY_REQUEST_URL,
219224
log_url: log_url
220225
})
221226
@@ -330,11 +335,12 @@ jobs:
330335
env:
331336
REF: ${{ needs.prechecks.outputs.ref }}
332337
comment: ${{ github.event.comment.body }}
338+
baseDirectory: ${{env.pscale_base_directory}}
333339
uses: actions/github-script@v3
334340
with:
335341
github-token: ${{ secrets.GITHUB_TOKEN }}
336342
script: |
337-
const { REF, comment } = process.env;
343+
const { REF, comment, baseDirectory } = process.env;
338344
339345
// check if comment starts with '/ps-create' and is only followed by whitespaces
340346
const regexCommandWithoutParameters = /^\/ps-create\s*$/
@@ -375,7 +381,7 @@ jobs:
375381
core.info("DDL statements: " + DDL_STATEMENTS)
376382
core.setOutput('DDL_STATEMENTS', DDL_STATEMENTS)
377383
378-
const ps_env_name = '.pscale/ps-env-' + REF + ".sh"
384+
const ps_env_name = baseDirectory + '/env/ps-env-' + REF + ".sh"
379385
// check whether file ps_env_name exists in the repo and given ref
380386
try {
381387
const response = await github.repos.getContent({
@@ -425,6 +431,7 @@ jobs:
425431
GITHUB_USER: ${{github.actor}}
426432
DDL_STATEMENTS: ${{ steps.validate_params.outputs.DDL_STATEMENTS }}
427433
BRANCH_NAME: ${{ steps.validate_params.outputs.BRANCH_NAME }}
434+
working-directory: ${{env.pscale_base_directory}}/cli-helper-scripts/
428435
run: |
429436
./create-db-branch-dr-and-connection.sh "$BRANCH_NAME" "$DDL_STATEMENTS"
430437
@@ -437,10 +444,11 @@ jobs:
437444
DEPLOY_REQUEST_NUMBER: ${{ steps.create-db-branch-and-dr.outputs.DEPLOY_REQUEST_NUMBER }}
438445
DEPLOY_REQUEST_URL: ${{ steps.create-db-branch-and-dr.outputs.DEPLOY_REQUEST_URL }}
439446
BRANCH_URL: ${{ steps.create-db-branch-and-dr.outputs.BRANCH_URL }}
447+
working-directory: ${{env.pscale_base_directory}}/cli-helper-scripts/
440448
run: |
441-
mkdir -p .pscale/
442-
envsubst < ps-env-template.sh > .pscale/ps-env-${REF}.sh
443-
chmod a+x .pscale/ps-env-${REF}.sh
449+
mkdir -p ../env/
450+
envsubst < ps-env-template.sh > ../env/ps-env-${BRANCH_NAME}.sh
451+
chmod a+x ../env/ps-env-${REF}.sh
444452
445453
- name: Commit changes
446454
uses: elstudio/actions-js-build/commit@v4
@@ -564,11 +572,12 @@ jobs:
564572
env:
565573
REF: ${{ needs.prechecks.outputs.ref }}
566574
comment: ${{ github.event.comment.body }}
575+
baseDirectory: ${{env.pscale_base_directory}}
567576
uses: actions/github-script@v3
568577
with:
569578
github-token: ${{ secrets.GITHUB_TOKEN }}
570579
script: |
571-
const { REF, comment } = process.env;
580+
const { REF, comment, baseDirectory } = process.env;
572581
573582
// check if comment starts with '/ps-update' and is only followed by whitespaces
574583
const regexCommandWithoutParameters = /^\/ps-update\s*$/
@@ -596,7 +605,7 @@ jobs:
596605
core.info("DDL statements: " + DDL_STATEMENTS)
597606
core.setOutput('DDL_STATEMENTS', DDL_STATEMENTS)
598607
599-
const ps_env_name = '.pscale/ps-env-' + REF + ".sh"
608+
const ps_env_name = baseDirectory + '/env/ps-env-' + REF + ".sh"
600609
// check whether file ps_env_name exists in the repo and given ref
601610
try {
602611
const response = await github.repos.getContent({
@@ -643,7 +652,8 @@ jobs:
643652
REF: ${{ needs.prechecks.outputs.ref }}
644653
GITHUB_USER: ${{github.actor}}
645654
DDL_STATEMENTS: ${{ steps.validate_params.outputs.DDL_STATEMENTS }}
646-
run: . .pscale/ps-env-${REF}.sh && ./update-db-branch.sh "$BRANCH_NAME" "$DDL_STATEMENTS" "$DEPLOY_REQUEST_NUMBER"
655+
working-directory: ${{env.pscale_base_directory}}/cli-helper-scripts/
656+
run: . ../env/ps-env-${REF}.sh && ./update-db-branch.sh "$BRANCH_NAME" "$DDL_STATEMENTS" "$DEPLOY_REQUEST_NUMBER"
647657

648658
- name: Database branch and DR update succeeded
649659
id: ps-update-succeeded
@@ -761,11 +771,12 @@ jobs:
761771
env:
762772
REF: ${{ needs.prechecks.outputs.ref }}
763773
comment: ${{ github.event.comment.body }}
774+
baseDirectory: ${{env.pscale_base_directory}}
764775
uses: actions/github-script@v3
765776
with:
766777
github-token: ${{ secrets.GITHUB_TOKEN }}
767778
script: |
768-
const { REF, comment } = process.env;
779+
const { REF, comment, baseDirectory } = process.env;
769780
770781
reviewComment = "LGTM"
771782
@@ -790,7 +801,7 @@ jobs:
790801
791802
core.setOutput('reviewComment', reviewComment)
792803
793-
const ps_env_name = '.pscale/ps-env-' + REF + ".sh"
804+
const ps_env_name = baseDirectory + '/env/ps-env-' + REF + ".sh"
794805
// check whether file ps_env_name exists in the repo and given ref
795806
try {
796807
const response = await github.repos.getContent({
@@ -837,7 +848,8 @@ jobs:
837848
REF: ${{ needs.prechecks.outputs.ref }}
838849
GITHUB_USER: ${{github.actor}}
839850
COMMENT: ${{steps.validate_params.outputs.reviewComment}}
840-
run: . .pscale/ps-env-${REF}.sh && ./approve-deploy-request.sh "$DEPLOY_REQUEST_NUMBER" "$COMMENT"
851+
working-directory: ${{env.pscale_base_directory}}/cli-helper-scripts/
852+
run: . ../env/ps-env-${REF}.sh && ./approve-deploy-request.sh "$DEPLOY_REQUEST_NUMBER" "$COMMENT"
841853

842854
- name: Approved deploy request
843855
id: ps-approve-succeeded
@@ -935,11 +947,12 @@ jobs:
935947
env:
936948
REF: ${{ needs.prechecks.outputs.ref }}
937949
comment: ${{ github.event.comment.body }}
950+
baseDirectory: ${{ env.pscale_base_directory }}
938951
uses: actions/github-script@v3
939952
with:
940953
github-token: ${{ secrets.GITHUB_TOKEN }}
941954
script: |
942-
const { REF, comment } = process.env;
955+
const { REF, comment, baseDirectory } = process.env;
943956
944957
// check if comment starts with '/ps-delete' and is only followed by whitespaces
945958
const regexCommandWithoutParameters = /^\/ps-delete\s*$/
@@ -953,7 +966,7 @@ jobs:
953966
throw new Error(message)
954967
}
955968
956-
const ps_env_name = '.pscale/ps-env-' + REF + ".sh"
969+
const ps_env_name = baseDirectory + '/env/ps-env-' + REF + ".sh"
957970
// check whether file ps_env_name exists in the repo and given ref
958971
try {
959972
const response = await github.repos.getContent({
@@ -999,7 +1012,8 @@ jobs:
9991012
PLANETSCALE_SERVICE_TOKEN: ${{secrets.PLANETSCALE_SERVICE_TOKEN}}
10001013
REF: ${{ needs.prechecks.outputs.ref }}
10011014
GITHUB_USER: ${{github.actor}}
1002-
run: . .pscale/ps-env-${REF}.sh && ./delete-db-branch.sh "$BRANCH_NAME"
1015+
working-directory: ${{env.pscale_base_directory}}/cli-helper-scripts/
1016+
run: . ../env/ps-env-${REF}.sh && ./delete-db-branch.sh "$BRANCH_NAME"
10031017

10041018
- name: Database branch deleted
10051019
id: ps-delete-succeeded

.github/workflows/merge-latest-open-deploy-request.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: 03 - Merge latest Deploy Request
22

33
on:
44
workflow_dispatch
5+
6+
env:
7+
pscale_base_directory: .pscale
58

69
jobs:
710

@@ -21,6 +24,7 @@ jobs:
2124
ORG_NAME: ${{secrets.ORG_NAME}}
2225
DB_NAME: ${{secrets.DB_NAME}}
2326
GITHUB_USER: ${{github.actor}}
27+
working-directory: ${{env.pscale_base_directory}}/cli-helper-scripts/
2428
run: ./merge-latest-open-deploy-request.sh
2529
- name: Please check out the result of your merge request from step above
2630
run: |

.github/workflows/remove-database.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name: XX - Remove Database
33
on:
44
workflow_dispatch
55

6+
env:
7+
pscale_base_directory: .pscale
8+
69
jobs:
710

811
remove-database:
@@ -20,4 +23,5 @@ jobs:
2023
ORG_NAME: ${{secrets.ORG_NAME}}
2124
DB_NAME: ${{secrets.DB_NAME}}
2225
GITHUB_USER: ${{github.actor}}
26+
working-directory: ${{env.pscale_base_directory}}/cli-helper-scripts/
2327
run: ./remove-database.sh

.github/workflows/remove-operation-column-and-index.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name: 04 - Del Operation Column & Index
33
on:
44
workflow_dispatch
55

6+
env:
7+
pscale_base_directory: .pscale
8+
69
jobs:
710

811
remove-operation-column-and-index:
@@ -21,6 +24,7 @@ jobs:
2124
ORG_NAME: ${{secrets.ORG_NAME}}
2225
DB_NAME: ${{secrets.DB_NAME}}
2326
GITHUB_USER: ${{github.actor}}
27+
working-directory: ${{env.pscale_base_directory}}/cli-helper-scripts/
2428
run: ./remove-operation-column-and-index.sh
2529
- name: Please check out deployment request and branch connection string from step above
2630
run: |

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
.venv/*
22
_actions/*
33
__pycache__/*
4-
typescript
4+
.pscale/cli-helper-scripts/typescript
5+
6+
# do not publish macOS blergh
7+
._*
8+
.DS_Store
9+
.DS_Store?
10+
.Spotlight-V100
11+
.Trashes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

ps-env-test-ps-create.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)