-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Your Name
committed
Sep 19, 2024
1 parent
7175c74
commit f4e7dcf
Showing
8 changed files
with
153 additions
and
58 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
const indent = require("./indent") | ||
|
||
module.exports = (aggregateError) => | ||
new Error( | ||
module.exports = (aggregateError) => { | ||
console.log("aggregateError", aggregateError) | ||
return new Error( | ||
`${aggregateError.name} ${aggregateError.message}: \n${indent( | ||
aggregateError.errors | ||
.map((error) => `${error.stack.toString()}`) | ||
.join("\n"), | ||
2 | ||
)}` | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
const { setTimeout: sleep } = require("timers/promises") | ||
const supabase = require("../lib/supabase") | ||
|
||
module.exports = async (_options, { config, dryRun, ctx }) => { | ||
if (dryRun) { | ||
return | ||
} | ||
|
||
const { | ||
gitSha, | ||
projectName, | ||
environment, | ||
gitBranch, | ||
repositoryName, | ||
gitRepositoryUrl, | ||
pipelineUUID, | ||
} = config | ||
|
||
const values = { | ||
uuid: pipelineUUID, | ||
commit_hash: gitSha, | ||
project: projectName, | ||
environment, | ||
branch: gitBranch, | ||
repository: repositoryName, | ||
repository_url: gitRepositoryUrl, | ||
} | ||
|
||
const eventsBucket = ctx.require("eventsBucket") | ||
// const abortController = ctx.require("abortController") | ||
|
||
// resource:waiting | ||
// resource:failed | ||
// resource:ready | ||
// resource:closed | ||
|
||
async function insertValues(data) { | ||
const { error } = await supabase.from("deployments_logs").insert([data]) | ||
if (error) throw error | ||
} | ||
|
||
const waitingFor = [] | ||
eventsBucket.on("resource:waiting", () => { | ||
waitingFor.push( | ||
new Promise(async (resolve, reject) => { | ||
try { | ||
const valuesToInsert = { ...values, status: "waiting" } | ||
await insertValues(valuesToInsert) | ||
resolve() | ||
} catch (e) { | ||
reject(e) | ||
} | ||
// await | ||
}) | ||
) | ||
}) | ||
|
||
eventsBucket.on("resource:ready", () => { | ||
waitingFor.push( | ||
new Promise(async (resolve, reject) => { | ||
try { | ||
const valuesToInsert = { ...values, status: "ready" } | ||
await insertValues(valuesToInsert) | ||
resolve() | ||
} catch (e) { | ||
reject(e) | ||
} | ||
// await | ||
}) | ||
) | ||
}) | ||
|
||
eventsBucket.on("resource:failed", () => { | ||
waitingFor.push( | ||
new Promise(async (resolve, reject) => { | ||
try { | ||
const valuesToInsert = { ...values, status: "failed" } | ||
await insertValues(valuesToInsert) | ||
resolve() | ||
} catch (e) { | ||
reject(e) | ||
} | ||
// await | ||
}) | ||
) | ||
}) | ||
|
||
let finished | ||
eventsBucket.on("deploy-with:finish", () => { | ||
finished = true | ||
}) | ||
|
||
return new Promise(async (res, rej) => { | ||
while (true) { | ||
if (finished) { | ||
console.log("WAITING FOR...") | ||
try { | ||
await Promise.all(waitingFor) | ||
res() | ||
} catch (err) { | ||
console.log("ERROR", err) | ||
rej(err) | ||
} | ||
return | ||
} | ||
await sleep(1) | ||
} | ||
}) | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const { createClient } = require("@supabase/supabase-js") | ||
Check failure on line 1 in plugins/kontinuous-ui/lib/supabase.js GitHub Actions / Lint
|
||
|
||
const { SUPABASE_URL: supabaseUrl, SUPABASE_KEY: supabaseKey } = process.env | ||
|
||
const supabase = createClient(supabaseUrl, supabaseKey) | ||
|
||
module.exports = supabase |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
const { createClient } = require("@supabase/supabase-js") | ||
|
||
module.exports = async (_manifests, _options, { config, ctx }) => { | ||
const processEnv = ctx.get("env") || process.env | ||
const { SUPABASE_URL: supabaseUrl, SUPABASE_KEY: supabaseKey } = processEnv | ||
const supabase = require("../lib/supabase") | ||
|
||
module.exports = async (_manifests, _options, { config, logger }) => { | ||
const { | ||
gitSha, | ||
projectName, | ||
environment, | ||
refLabelValue, | ||
gitBranch, | ||
repositoryName, | ||
actionCommandName, | ||
gitRepositoryUrl, | ||
pipelineUUID, | ||
} = config | ||
|
||
const supabase = createClient(supabaseUrl, supabaseKey) | ||
const values = { | ||
uuid: pipelineUUID, | ||
status: "pre-deploy", | ||
commit_hash: gitSha, | ||
project: projectName, | ||
environment, | ||
branch: gitBranch, | ||
repository: repositoryName, | ||
repository_url: gitRepositoryUrl, | ||
} | ||
|
||
const { error } = await supabase.from("deployments_logs").insert([ | ||
{ | ||
status: actionCommandName, | ||
commit_hash: gitSha, | ||
project: projectName, | ||
environment, | ||
branch: refLabelValue, | ||
repository: repositoryName, | ||
}, | ||
]) | ||
const { error } = await supabase.from("deployments_logs").insert([values]) | ||
|
||
if (error) throw error | ||
|
||
logger.info(values, "FINISHED") | ||
} |
This file contains 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