| 180 | } |
| 181 | |
| 182 | async function stepDbtRepoCheck(client) { |
| 183 | const secret = need('RUNNING_SECRET'); |
| 184 | const org = await orgUuid(client); |
| 185 | const r = await client.query( |
| 186 | `SELECT project_uuid, encode(dbt_connection,'hex') AS hex |
| 187 | FROM projects WHERE organization_id=(SELECT organization_id FROM organizations WHERE organization_uuid=$1) |
| 188 | ORDER BY project_id LIMIT 1`, [org]); |
| 189 | if (!r.rows.length) { console.log('OK: no project to check'); return; } |
| 190 | let type = '?'; |
| 191 | try { type = (JSON.parse(decrypt(Buffer.from(r.rows[0].hex, 'hex'), secret)).type) || '?'; } catch (_) {} |
| 192 | if (type === 'github' || type === 'gitlab') { |
| 193 | console.log(`OK: project ${r.rows[0].project_uuid} dbt_connection is '${type}' (writeback-capable)`); |
| 194 | } else { |
| 195 | console.log(`NEED: project ${r.rows[0].project_uuid} dbt_connection is '${type}', not github/gitlab — repoint it (guided: see the GitHub Integration section) for writeback to open PRs`); |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | async function installationToken(client) { |
| 200 | const secret = need('RUNNING_SECRET'); |