Skip to content

Commit ee59416

Browse files
committed
chore: remove baseline from main branch
1 parent 7cd15bf commit ee59416

File tree

2 files changed

+42
-96
lines changed

2 files changed

+42
-96
lines changed

.github/workflows/pgschema-multifile-plan.yml

Lines changed: 21 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ on:
44
pull_request:
55
types: [opened, synchronize, reopened]
66
paths:
7-
- 'multifile/**'
8-
- '.github/workflows/pgschema-plan-multi.yml'
7+
- "multifile/**"
8+
- ".github/workflows/pgschema-plan-multi.yml"
99

1010
permissions:
1111
contents: read
@@ -14,10 +14,10 @@ permissions:
1414
jobs:
1515
pgschema-plan-multi:
1616
runs-on: ubuntu-latest
17-
17+
1818
env:
1919
PGPASSWORD: postgres
20-
20+
2121
services:
2222
postgres:
2323
image: postgres:17
@@ -32,46 +32,19 @@ jobs:
3232
--health-retries 5
3333
ports:
3434
- 5432:5432
35-
35+
3636
steps:
3737
- name: Checkout code
3838
uses: actions/checkout@v4
39-
39+
4040
- name: Setup Go
4141
uses: actions/setup-go@v5
4242
with:
43-
go-version: 'stable'
44-
43+
go-version: "stable"
44+
4545
- name: Install pgschema
4646
run: go install github.com/pgschema/pgschema@latest
47-
48-
- name: Setup baseline schema from main branch
49-
run: |
50-
# Checkout main branch to get baseline schema
51-
git fetch origin main
52-
git checkout origin/main -- multifile/ || {
53-
echo "::error::Could not checkout multifile/ from main branch"
54-
exit 1
55-
}
56-
57-
# Copy main branch schema to temporary location
58-
cp -r multifile /tmp/main_multifile
59-
60-
# Restore current branch schema
61-
git checkout HEAD -- multifile/
62-
63-
# Apply main branch schema to establish baseline database state
64-
echo "::group::Applying baseline schema"
65-
pgschema apply \
66-
--auto-approve \
67-
--host localhost \
68-
--port 5432 \
69-
--db testdb \
70-
--user postgres \
71-
--file /tmp/main_multifile/main.sql \
72-
|| echo "::warning::Failed to apply baseline schema"
73-
echo "::endgroup::"
74-
47+
7548
- name: Run pgschema plan
7649
id: plan
7750
run: |
@@ -83,47 +56,47 @@ jobs:
8356
--user postgres \
8457
--file "${{ github.workspace }}/multifile/main.sql" \
8558
--format human 2>&1)
86-
59+
8760
# Set output
8861
echo "plan<<EOF" >> $GITHUB_OUTPUT
8962
echo "$PLAN_OUTPUT" >> $GITHUB_OUTPUT
9063
echo "EOF" >> $GITHUB_OUTPUT
91-
64+
9265
- name: Comment PR
9366
uses: actions/github-script@v7
9467
with:
9568
github-token: ${{secrets.GITHUB_TOKEN}}
9669
script: |
9770
const planOutput = `${{ steps.plan.outputs.plan }}`;
98-
71+
9972
// Decode the escaped output
10073
const decodedOutput = decodeURIComponent(planOutput);
101-
74+
10275
const body = `## pgschema Plan Output
103-
76+
10477
<details>
10578
<summary>Click to expand plan details</summary>
106-
79+
10780
\`\`\`
10881
${decodedOutput}
10982
\`\`\`
110-
83+
11184
</details>
112-
85+
11386
---
11487
*This comment was automatically generated by the pgschema Multi File Plan workflow.*`;
115-
88+
11689
// Try to find existing comment
11790
const { data: comments } = await github.rest.issues.listComments({
11891
...context.repo,
11992
issue_number: context.issue.number,
12093
});
121-
94+
12295
const botComment = comments.find(comment =>
12396
comment.user.type === 'Bot' &&
12497
comment.body.includes('pgschema Plan Output')
12598
);
126-
99+
127100
if (botComment) {
128101
// Update existing comment
129102
await github.rest.issues.updateComment({
@@ -138,4 +111,4 @@ jobs:
138111
issue_number: context.issue.number,
139112
body: body
140113
});
141-
}
114+
}

.github/workflows/pgschema-singlefile-plan.yml

Lines changed: 21 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ on:
44
pull_request:
55
types: [opened, synchronize, reopened]
66
paths:
7-
- 'singlefile/**'
8-
- '.github/workflows/pgschema-plan-single.yml'
7+
- "singlefile/**"
8+
- ".github/workflows/pgschema-plan-single.yml"
99

1010
permissions:
1111
contents: read
@@ -14,10 +14,10 @@ permissions:
1414
jobs:
1515
pgschema-plan-single:
1616
runs-on: ubuntu-latest
17-
17+
1818
env:
1919
PGPASSWORD: postgres
20-
20+
2121
services:
2222
postgres:
2323
image: postgres:17
@@ -32,46 +32,19 @@ jobs:
3232
--health-retries 5
3333
ports:
3434
- 5432:5432
35-
35+
3636
steps:
3737
- name: Checkout code
3838
uses: actions/checkout@v4
39-
39+
4040
- name: Setup Go
4141
uses: actions/setup-go@v5
4242
with:
43-
go-version: 'stable'
44-
43+
go-version: "stable"
44+
4545
- name: Install pgschema
4646
run: go install github.com/pgschema/pgschema@latest
47-
48-
- name: Setup baseline schema from main branch
49-
run: |
50-
# Checkout main branch to get baseline schema
51-
git fetch origin main
52-
git checkout origin/main -- singlefile/schema.sql || {
53-
echo "::error::Could not checkout schema.sql from main branch"
54-
exit 1
55-
}
56-
57-
# Copy main branch schema to temporary location
58-
cp singlefile/schema.sql /tmp/main_schema.sql
59-
60-
# Restore current branch schema
61-
git checkout HEAD -- singlefile/schema.sql
62-
63-
# Apply main branch schema to establish baseline database state
64-
echo "::group::Applying baseline schema"
65-
pgschema apply \
66-
--auto-approve \
67-
--host localhost \
68-
--port 5432 \
69-
--db testdb \
70-
--user postgres \
71-
--file /tmp/main_schema.sql \
72-
|| echo "::warning::Failed to apply baseline schema"
73-
echo "::endgroup::"
74-
47+
7548
- name: Run pgschema plan
7649
id: plan
7750
run: |
@@ -84,47 +57,47 @@ jobs:
8457
--user postgres \
8558
--file "${{ github.workspace }}/singlefile/schema.sql" \
8659
--format human 2>&1)
87-
60+
8861
# Set output
8962
echo "plan<<EOF" >> $GITHUB_OUTPUT
9063
echo "$PLAN_OUTPUT" >> $GITHUB_OUTPUT
9164
echo "EOF" >> $GITHUB_OUTPUT
92-
65+
9366
- name: Comment PR
9467
uses: actions/github-script@v7
9568
with:
9669
github-token: ${{secrets.GITHUB_TOKEN}}
9770
script: |
9871
const planOutput = `${{ steps.plan.outputs.plan }}`;
99-
72+
10073
// Decode the escaped output
10174
const decodedOutput = decodeURIComponent(planOutput);
102-
75+
10376
const body = `## pgschema Plan Output
104-
77+
10578
<details>
10679
<summary>Click to expand plan details</summary>
107-
80+
10881
\`\`\`
10982
${decodedOutput}
11083
\`\`\`
111-
84+
11285
</details>
113-
86+
11487
---
11588
*This comment was automatically generated by the pgschema Single File Plan workflow.*`;
116-
89+
11790
// Try to find existing comment
11891
const { data: comments } = await github.rest.issues.listComments({
11992
...context.repo,
12093
issue_number: context.issue.number,
12194
});
122-
95+
12396
const botComment = comments.find(comment =>
12497
comment.user.type === 'Bot' &&
12598
comment.body.includes('pgschema Plan Output')
12699
);
127-
100+
128101
if (botComment) {
129102
// Update existing comment
130103
await github.rest.issues.updateComment({
@@ -139,4 +112,4 @@ jobs:
139112
issue_number: context.issue.number,
140113
body: body
141114
});
142-
}
115+
}

0 commit comments

Comments
 (0)