diff --git a/dist/notify.mjs b/dist/notify.mjs new file mode 100755 index 0000000..4a51f75 --- /dev/null +++ b/dist/notify.mjs @@ -0,0 +1,66 @@ +import { a as coreExports, b as getOctokit_1, e as context } from './github-b307e6bd.mjs'; +import 'os'; +import 'fs'; +import 'path'; +import 'http'; +import 'https'; +import 'net'; +import 'tls'; +import 'events'; +import 'assert'; +import 'util'; +import 'module'; +import 'stream'; +import 'buffer'; +import 'querystring'; +import 'stream/web'; +import 'node:stream'; +import 'node:util'; +import 'node:events'; +import 'worker_threads'; +import 'perf_hooks'; +import 'util/types'; +import 'async_hooks'; +import 'console'; +import 'url'; +import 'zlib'; +import 'string_decoder'; +import 'diagnostics_channel'; + +async function run() { + const token = coreExports.getInput("github-token"); + const octokit = getOctokit_1(token); + const { eventName, repo, runId } = context; + console.log(context); + console.log(process.env); + console.log({ + owner: repo.owner, + repo: repo.repo, + run_id: runId + }); + console.log("Event:", eventName); + if (eventName !== "push") { + return; + } + const jobInfo = await octokit.rest.actions.listJobsForWorkflowRun({ + owner: repo.owner, + repo: repo.repo, + run_id: runId + }); + console.log("Jobs:", jobInfo.data.jobs); + const job = jobInfo.data.jobs.find((job2) => job2.name === process.env.GITHUB_JOB); + console.log("Job:", job); + if (!job) { + return; + } + console.log("Job ID:", job.id); + console.log("Job URL:", job.html_url); + console.log("Job Status:", job.status); +} +run().catch((error) => { + if ("message" in error) { + coreExports.setFailed(error.message); + } else { + coreExports.setFailed("Unknown error: " + JSON.stringify(error)); + } +}); diff --git a/src/notify.ts b/src/notify.ts new file mode 100644 index 0000000..8f5fd01 --- /dev/null +++ b/src/notify.ts @@ -0,0 +1,55 @@ +import * as core from '@actions/core' +import * as github from '@actions/github' + +import path from 'node:path' +import resolve from 'resolve-package-path' +import { execa } from 'execa' + +const UNIQUE_IDENTIFIER = ''; + +async function run(): Promise { + const token = core.getInput('github-token') + const octokit = github.getOctokit(token) + const { eventName, repo, runId } = github.context; + console.log(github.context); + console.log(process.env); + console.log({ + owner: repo.owner, + repo: repo.repo, + run_id: runId + }); + + // On push to any branch defined in `on: ...`, run `astro db push` + console.log('Event:', eventName); + + if (eventName !== 'push') { + return; + } + + const jobInfo = await octokit.rest.actions.listJobsForWorkflowRun({ + owner: repo.owner, + repo: repo.repo, + run_id: runId + }); + console.log('Jobs:', jobInfo.data.jobs); + const job = jobInfo.data.jobs.find(job => job.name === process.env.GITHUB_JOB); + console.log('Job:', job); + if (!job) { + return; + } + console.log('Job ID:', job.id); + console.log('Job URL:', job.html_url); + console.log('Job Status:', job.status); + + // Notify Astro Studio that this has just begin + // +} + + +run().catch((error) => { + if ('message' in error) { + core.setFailed(error.message) + } else { + core.setFailed('Unknown error: ' + JSON.stringify(error)) + } +});