Skip to content

Commit

Permalink
update notify
Browse files Browse the repository at this point in the history
  • Loading branch information
FredKSchott committed Mar 11, 2024
1 parent 00dcaeb commit 3a1ee62
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 0 deletions.
66 changes: 66 additions & 0 deletions dist/notify.mjs
Original file line number Diff line number Diff line change
@@ -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));
}
});
55 changes: 55 additions & 0 deletions src/notify.ts
Original file line number Diff line number Diff line change
@@ -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 = '<!-- @astrojs/action-studio -->';

async function run(): Promise<void> {
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))
}
});

0 comments on commit 3a1ee62

Please sign in to comment.