Skip to content

Commit

Permalink
feat: action info
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelramos committed Jul 20, 2024
1 parent a5b126e commit 9f8e5c4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/log_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ jobs:
- uses: actions/github-script@v7
with:
script: |
const { logging } = await import('${{ github.workspace }}/test.mjs');
logging({ github, context, core });
const root = '${{ github.workspace }}';
const { getActionInfo } = await import('${{ github.workspace }}/actions.mjs');
console.log(getActionInfo({ context, root }));
19 changes: 19 additions & 0 deletions actions.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { getProjectRootPath } from '@websublime/workspace-tools';
import { inspect } from 'node:util';

function log(...args) {
console.log(inspect(args, { showHidden: false, depth: null, colors: true }))
}

export function getActionInfo({ context, root }) {
let projectRoot = getProjectRootPath(root);

return {
projectRoot,
commitIdBefore: context?.payload?.before,
commitIdAfter: context?.payload?.after,
ref: context?.payload?.ref,
eventName: context?.eventName,
headRef: context?.payload?.pull_request?.head?.ref,
}
}

0 comments on commit 9f8e5c4

Please sign in to comment.