Skip to content

Commit

Permalink
Merge pull request #230 from roryabraham/Rory-AddWorkflowRunAttachment
Browse files Browse the repository at this point in the history
Add workflowRun field
  • Loading branch information
8398a7 authored Nov 26, 2022
2 parents d64b11c + 7c86ac7 commit 2780b65
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/content/usage/fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Corresponding types are as follows.
| eventName | `AS_EVENT_NAME` | trigger event name |
| ref | `AS_REF` | git reference |
| workflow | `AS_WORKFLOW` | Generate a workflow link from git sha |
| workflowRun | `AS_WORKFLOW_RUN` | Generate a link to the present workflow run |
| message | `AS_MESSAGE` | commit message |
| author | `AS_AUTHOR` | The author who pushed |
| job | `AS_JOB` | Generate a job run link of the job that was executed |
Expand Down
10 changes: 10 additions & 0 deletions src/fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ export class FieldFactory {
this.includes('workflow')
? createAttachment('workflow', await this.workflow())
: undefined,
this.includes('workflowRun')
? createAttachment('workflow', await this.workflowRun())
: undefined,
this.includes('pullRequest')
? createAttachment('pullRequest', await this.pullRequest())
: undefined,
Expand Down Expand Up @@ -214,6 +217,13 @@ export class FieldFactory {
return value;
}

private async workflowRun(): Promise<string> {
const { owner, repo } = context.repo;
const value = `<${this.gitHubBaseUrl}/${owner}/${repo}/actions/runs/${context.runId}|${context.workflow}>`;
process.env.AS_WORKFLOW_RUN = value;
return value;
}

private async pullRequest(): Promise<string> {
let value;
if (context.eventName.startsWith('pull_request')) {
Expand Down

0 comments on commit 2780b65

Please sign in to comment.