55 branches :
66 - main
77 paths :
8- - ' singlefile/**'
9- - ' .github/workflows/pgschema-singlefile-apply.yml'
8+ - " singlefile/**"
9+ - " .github/workflows/pgschema-singlefile-apply.yml"
1010
1111permissions :
1212 contents : read
1313
1414jobs :
1515 pgschema-apply-single :
1616 runs-on : ubuntu-latest
17-
17+
1818 env :
1919 PGPASSWORD : postgres
20-
20+
2121 services :
2222 postgres :
2323 image : postgres:17
@@ -32,30 +32,30 @@ 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-
47+
4848 - name : Load baseline schema
4949 run : |
5050 echo "::group::Loading baseline schema to emulate remote database"
5151 PGPASSWORD=postgres psql -h localhost -p 5432 -U postgres -d testdb -f baseline.sql
5252 echo "::endgroup::"
53-
53+
5454 - name : Run pgschema apply
5555 id : apply
5656 run : |
5757 echo "::group::Applying schema changes"
58-
58+
5959 # Run pgschema apply with auto-approve
6060 APPLY_OUTPUT=$(pgschema apply \
6161 --auto-approve \
@@ -68,24 +68,24 @@ jobs:
6868 --lock-timeout "30s" \
6969 --application-name "pgschema-github-action-apply" \
7070 --format human 2>&1)
71-
71+
7272 APPLY_EXIT_CODE=$?
73-
73+
7474 # Output the results
7575 echo "$APPLY_OUTPUT"
76-
76+
7777 echo "::endgroup::"
78-
78+
7979 # Set outputs for potential future use
8080 echo "output<<EOF" >> $GITHUB_OUTPUT
8181 echo "$APPLY_OUTPUT" >> $GITHUB_OUTPUT
8282 echo "EOF" >> $GITHUB_OUTPUT
83-
83+
8484 echo "exit_code=$APPLY_EXIT_CODE" >> $GITHUB_OUTPUT
85-
85+
8686 # Exit with the same code as pgschema
8787 exit $APPLY_EXIT_CODE
88-
88+
8989 - name : Report Success
9090 if : success()
9191 run : |
@@ -94,15 +94,10 @@ jobs:
9494 echo "Applied to database: testdb"
9595 echo "Application name: pgschema-github-action-apply"
9696 echo "Lock timeout: 30s"
97-
97+
9898 - name : Report Failure
9999 if : failure()
100100 run : |
101101 echo "❌ Failed to apply schema changes!"
102102 echo ""
103103 echo "Please check the logs above for details."
104- echo "Common issues:"
105- echo "- Schema syntax errors"
106- echo "- Database connection issues"
107- echo "- Lock timeout exceeded"
108- echo "- Incompatible schema changes"
0 commit comments