Skip to content

Commit

Permalink
feat: ✨ Log context
Browse files Browse the repository at this point in the history
  • Loading branch information
robvanderleek committed Dec 6, 2024
1 parent 3a4fcbe commit 52f6513
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ on:
branches:
- main
pull_request:
branches: main
branches:
- main

jobs:
main:
if: github.repository == 'getcodelimit/codelimit-action'
runs-on: ubuntu-latest
permissions:
contents: write
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
build/
src/version.ts
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "",
"main": "action.js",
"scripts": {
"prepare": "node src/generate-versionjs.js > src/version.ts",
"build": "tsc",
"start": "yarn build && node ./build/action.js",
"dist": "yarn build && esbuild build/action.js --bundle --platform=node --outfile=dist/index.js",
Expand Down
3 changes: 3 additions & 0 deletions src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
import {exec, getExecOutput} from "@actions/exec";
import {downloadCodeLimitBinary, getBadgeContent, getReportContent} from "./codelimit";
import {getChangedFiles} from "./utils";
import {version} from "./version";

async function generateMarkdownReport(clBinary: string) {
const totalsMarkdown = await getExecOutput(clBinary, ['report', '--totals', '--format', 'markdown']);
Expand Down Expand Up @@ -80,6 +81,8 @@ async function checkChangedFiles(octokit: Octokit, clBinary: string): Promise<nu
}

async function main() {
console.log(`Code Limit action, version: ${version.revision}`);
console.log(JSON.stringify(context));
let exitCode = 0;
const clBinary = await downloadCodeLimitBinary();
console.log('Scanning codebase...');
Expand Down
3 changes: 3 additions & 0 deletions src/generate-versionjs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const execSync = require('child_process').execSync;
const output = execSync('git rev-parse --short HEAD', {encoding: 'utf-8'});
console.log('export const version = {\n "revision": "' + output.trim() + '",\n "year": "' + new Date().getFullYear() + '"\n}');
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,9 @@
form-data "^4.0.0"

"@types/node@*", "@types/node@^22.10.0":
version "22.10.0"
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.10.0.tgz#89bfc9e82496b9c7edea3382583fa94f75896e81"
integrity sha512-XC70cRZVElFHfIUB40FgZOBbgJYFKKMa5nb9lxcwYstFG/Mi+/Y0bGS+rs6Dmhmkpq4pnNiLiuZAbc02YCOnmA==
version "22.10.1"
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.10.1.tgz#41ffeee127b8975a05f8c4f83fb89bcb2987d766"
integrity sha512-qKgsUwfHZV2WCWLAnVP1JqnpE6Im6h3Y0+fYgMTasNQ7V++CBX5OT1as0g0f+OyubbFqhf6XVNIsmN4IIhEgGQ==
dependencies:
undici-types "~6.20.0"

Expand Down

0 comments on commit 52f6513

Please sign in to comment.