Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,8 @@ The action automatically includes the following metadata from the GitHub context
- `source_system` - Always set to `"github"`
- `build_number` - GitHub Actions run number
- `invoke_id` - GitHub Actions run ID
- `build_url` - Link to the GitHub Actions run
- `deploy_url` - Link to the GitHub Actions workflow run (for deployment events)
- `build_url` - Link to the GitHub Actions workflow run (for build events)
- `deployed_by` / `built_by` - GitHub username who triggered the workflow
- `deployed_by_email` / `built_by_email` - Email from commit author (when available)
- `deployed_by_name` / `built_by_name` - Full name from commit author (when available)
Expand Down
10 changes: 5 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34916,8 +34916,8 @@ const github = __importStar(__nccwpck_require__(3228));
function getGitHubMetadata() {
const { context } = github;
const { repo, runId, runNumber, sha, actor, ref, payload } = context;
// Construct build URL
const buildUrl = `https://github.com/${repo.owner}/${repo.repo}/actions/runs/${runId}`;
// Construct workflow run URL
const workflowRunUrl = `https://github.com/${repo.owner}/${repo.repo}/actions/runs/${runId}`;
// Extract branch name from ref (e.g., refs/heads/main -> main)
const scmBranch = ref.startsWith('refs/heads/') ? ref.replace('refs/heads/', '') : ref;
// Try to get email and name from commit author (available in push events)
Expand All @@ -34930,7 +34930,7 @@ function getGitHubMetadata() {
source_system: 'github',
build_number: String(runNumber),
invoke_id: String(runId),
build_url: buildUrl,
workflow_run_url: workflowRunUrl,
deployed_by: actor,
deployed_by_email: email,
deployed_by_name: name,
Expand Down Expand Up @@ -35127,7 +35127,7 @@ async function run() {
version: inputs.version,
status: inputs.status,
build_number: githubMetadata.build_number,
build_url: githubMetadata.build_url,
build_url: githubMetadata.workflow_run_url,
scm_repository: githubMetadata.scm_repository,
scm_sha: githubMetadata.scm_sha,
scm_branch: githubMetadata.scm_branch,
Expand Down Expand Up @@ -35169,7 +35169,7 @@ async function run() {
source_system: githubMetadata.source_system,
build_number: githubMetadata.build_number,
invoke_id: githubMetadata.invoke_id,
build_url: githubMetadata.build_url,
deploy_url: githubMetadata.workflow_run_url,
deployed_by: githubMetadata.deployed_by,
deployed_by_email: githubMetadata.deployed_by_email,
deployed_by_name: githubMetadata.deployed_by_name,
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface DeploymentEventPayload {
source_system?: string;
build_number?: string;
invoke_id?: string;
build_url?: string;
deploy_url?: string;
deployed_by?: string;
deployed_by_email?: string;
deployed_by_name?: string;
Expand Down Expand Up @@ -78,7 +78,7 @@ export interface GitHubMetadata {
source_system: string;
build_number: string;
invoke_id: string;
build_url: string;
workflow_run_url: string;
deployed_by: string;
deployed_by_email?: string;
deployed_by_name?: string;
Expand Down
2 changes: 1 addition & 1 deletion dist/types.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions src/__tests__/github-context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@ describe('getGitHubMetadata', () => {
source_system: 'github',
build_number: '42',
invoke_id: '12345',
build_url: 'https://github.com/test-owner/test-repo/actions/runs/12345',
workflow_run_url: 'https://github.com/test-owner/test-repo/actions/runs/12345',
deployed_by: 'test-user',
})
})

it('should construct correct build URL', () => {
it('should construct correct workflow run URL', () => {
const metadata = getGitHubMetadata()

expect(metadata.build_url).toBe('https://github.com/test-owner/test-repo/actions/runs/12345')
expect(metadata.workflow_run_url).toBe(
'https://github.com/test-owner/test-repo/actions/runs/12345'
)
})
})

Expand Down
6 changes: 3 additions & 3 deletions src/github-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export function getGitHubMetadata(): GitHubMetadata {
const { context } = github
const { repo, runId, runNumber, sha, actor, ref, payload } = context

// Construct build URL
const buildUrl = `https://github.com/${repo.owner}/${repo.repo}/actions/runs/${runId}`
// Construct workflow run URL
const workflowRunUrl = `https://github.com/${repo.owner}/${repo.repo}/actions/runs/${runId}`

// Extract branch name from ref (e.g., refs/heads/main -> main)
const scmBranch = ref.startsWith('refs/heads/') ? ref.replace('refs/heads/', '') : ref
Expand All @@ -25,7 +25,7 @@ export function getGitHubMetadata(): GitHubMetadata {
source_system: 'github',
build_number: String(runNumber),
invoke_id: String(runId),
build_url: buildUrl,
workflow_run_url: workflowRunUrl,
deployed_by: actor,
deployed_by_email: email,
deployed_by_name: name,
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ async function run(): Promise<void> {
version: inputs.version,
status: inputs.status,
build_number: githubMetadata.build_number,
build_url: githubMetadata.build_url,
build_url: githubMetadata.workflow_run_url,
scm_repository: githubMetadata.scm_repository,
scm_sha: githubMetadata.scm_sha,
scm_branch: githubMetadata.scm_branch,
Expand Down Expand Up @@ -188,7 +188,7 @@ async function run(): Promise<void> {
source_system: githubMetadata.source_system,
build_number: githubMetadata.build_number,
invoke_id: githubMetadata.invoke_id,
build_url: githubMetadata.build_url,
deploy_url: githubMetadata.workflow_run_url,
deployed_by: githubMetadata.deployed_by,
deployed_by_email: githubMetadata.deployed_by_email,
deployed_by_name: githubMetadata.deployed_by_name,
Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface DeploymentEventPayload {
source_system?: string
build_number?: string
invoke_id?: string
build_url?: string
deploy_url?: string
deployed_by?: string
deployed_by_email?: string
deployed_by_name?: string
Expand Down Expand Up @@ -84,7 +84,7 @@ export interface GitHubMetadata {
source_system: string
build_number: string
invoke_id: string
build_url: string
workflow_run_url: string
deployed_by: string
deployed_by_email?: string
deployed_by_name?: string
Expand Down