-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yaml
More file actions
101 lines (89 loc) · 3.44 KB
/
action.yaml
File metadata and controls
101 lines (89 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# code=yaml
# yaml-language-server: $schema=https://raw.githubusercontent.com/SchemaStore/schemastore/refs/heads/master/src/schemas/json/github-action.json
name: "Query Doctor"
description: "Query Doctor"
branding:
icon: "database"
color: "blue"
inputs:
postgres-version:
description: "PostgreSQL version to use (14, 17, or 18)"
required: true
default: "18"
runs:
using: "composite"
steps:
- name: Install Node.js
uses: actions/setup-node@v6
with:
node-version: 24
- name: Install dependencies
shell: bash
working-directory: ${{ github.action_path }}
run: npm ci
# Cache pgBadger build
- name: Cache pgBadger
uses: actions/cache@v4
id: pgbadger-cache
with:
path: /usr/local/bin/pgbadger
key: pgbadger-${{ runner.os }}-v13.1
# Install pgbadger dependencies (using apt for Ubuntu runners)
- name: Install pgBadger Dependencies
shell: bash
if: steps.pgbadger-cache.outputs.cache-hit != 'true'
run: |
sudo apt-get update
sudo apt-get install -y perl make wget postgresql-client
# Download, build, and install pgBadger
- name: Download and Install pgBadger
shell: bash
if: steps.pgbadger-cache.outputs.cache-hit != 'true'
run: |
PGBADGER_VERSION=13.1
cd /tmp
wget https://github.com/darold/pgbadger/archive/v${PGBADGER_VERSION}.tar.gz -O pgbadger.tar.gz
tar -xzf pgbadger.tar.gz
cd pgbadger-${PGBADGER_VERSION}
perl Makefile.PL
sudo make install # Use sudo to install globally
cd ${{ github.action_path }} # Return to action directory
- name: Cache postgresql-client
uses: actions/cache@v4
id: pg-client-cache
with:
path: /usr/lib/postgresql/${{ inputs.postgres-version }}
key: pg-client-${{ runner.os }}-${{ inputs.postgres-version }}
- name: Install postgresql-client
shell: bash
if: steps.pg-client-cache.outputs.cache-hit != 'true'
run: |
sudo apt-get install -y curl ca-certificates
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo gpg --dearmor -o /usr/share/keyrings/postgresql.gpg
echo "deb [signed-by=/usr/share/keyrings/postgresql.gpg] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
sudo apt-get update
sudo apt-get install -y postgresql-client-${{ inputs.postgres-version }}
- name: Start PostgreSQL
shell: bash
run: |
PORT=$(shuf -i 10000-65000 -n 1)
echo "PG_PORT=$PORT" >> $GITHUB_ENV
echo "PG_DUMP_BINARY=/usr/lib/postgresql/${{ inputs.postgres-version }}/bin/pg_dump" >> $GITHUB_ENV
echo "PG_RESTORE_BINARY=/usr/lib/postgresql/${{ inputs.postgres-version }}/bin/pg_restore" >> $GITHUB_ENV
docker run -d \
--name query-doctor-postgres \
-p $PORT:5432 \
ghcr.io/query-doctor/postgres:pg-${{ inputs.postgres-version }}
until docker exec query-doctor-postgres pg_isready -U postgres; do
sleep 1
done
# Run the application
- name: Run Analyzer
shell: bash
working-directory: ${{ github.action_path }}
run: npm run start
env:
CI: "true"
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
SITE_API_ENDPOINT: ${{ env.SITE_API_ENDPOINT }}
POSTGRES_URL: postgresql://postgres@localhost:${{ env.PG_PORT }}/postgres