FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat: add city column · pgplex/pgschema-github-actions-example@8f31dba · GitHub

feat: add city column #5

feat: add city column

feat: add city column #5

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
name: pgschema Plan - Single File
on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- "singlefile/**"
- ".github/workflows/pgschema-plan-single.yml"
permissions:
contents: read
pull-requests: write
jobs:
pgschema-plan-single:
runs-on: ubuntu-latest
env:
PGPASSWORD: postgres
services:
postgres:
image: postgres:17
env:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: testdb
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "stable"
- name: Install pgschema
run: go install github.com/pgschema/pgschema@latest
- name: Load baseline schema
run: |
echo "::group::Loading baseline schema to emulate remote database"
PGPASSWORD=postgres psql -h localhost -p 5432 -U postgres -d testdb -f baseline.sql
echo "::endgroup::"
- name: Run pgschema plan
id: plan
run: |
echo "Running pgschema plan with detailed logging..."
# Enable detailed error reporting
set -x # Show commands as they execute
# Run pgschema plan
PLAN_OUTPUT=$(pgschema plan \
--debug \
--host localhost \
--port 5432 \
--db testdb \
--user postgres \
--file "${{ github.workspace }}/singlefile/schema.sql" \
2>&1)
set +x # Disable command tracing
# Set output
echo "plan<<EOF" >> $GITHUB_OUTPUT
echo "$PLAN_OUTPUT" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Comment PR
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const planOutput = `${{ steps.plan.outputs.plan }}`;
const decodedOutput = planOutput;
const body = `## pgschema Plan Output
<details>
<summary>Click to expand plan details</summary>
\`\`\`
${decodedOutput}
\`\`\`
</details>
---
*This comment was automatically generated by the [pgschema](https://www.pgschema.com) Single File Plan workflow.*`;
// Try to find existing comment
const { data: comments } = await github.rest.issues.listComments({
...context.repo,
issue_number: context.issue.number,
});
const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('pgschema Plan Output')
);
if (botComment) {
// Update existing comment
await github.rest.issues.updateComment({
...context.repo,
comment_id: botComment.id,
body: body
});
} else {
// Create new comment
await github.rest.issues.createComment({
...context.repo,
issue_number: context.issue.number,
body: body
});
}

Back | FazBrowse Home | New Git URL