mirror of
https://github.com/actions/runner.git
synced 2025-12-10 20:36:49 +00:00
Runner Job Started/Completed Hooks (#1737)
* Prototype for pre job hook * Remove debug log * Enable hooks again * Initialize with hostContext * Add event_path, fix no-path bug * Allow script post steps * Call script handler with correct pre post stage * Add job completed hook * Make filecommand work and hardcode shell * Conditionally print step details and no telemetry for hooks * Figure out whih script to use * Only check path for managed scripts * Resture win dependency * Nits * Remove unused, add named params * Telemetry + refactoring * add message to job * rename hooks remove stale comment * cleanup * Use .CreateService to create step * Add L0s * pr feedback * update tests * add disclaimer, clean up code * spacing fix * little more cleanup * pr fix * pr feedback * Refactor to use JobExtension * fix tests * fix typo * cleanup code * more cleanup * little more cleanup * last bit of cleanup * fix tests * nit fix * Update src/Runner.Worker/JobHookProvider.cs Co-authored-by: Edward Thomson <ethomson@github.com> * don't override runner telemtry * pr feedback * pr feedback * pr feedback Co-authored-by: Thomas Boop <thboop@github.com> Co-authored-by: Thomas Boop <52323235+thboop@users.noreply.github.com> Co-authored-by: Edward Thomson <ethomson@github.com>
This commit is contained in:
@@ -109,6 +109,7 @@ namespace GitHub.Runner.Worker
|
||||
void ForceTaskComplete();
|
||||
void RegisterPostJobStep(IStep step);
|
||||
void PublishStepTelemetry();
|
||||
void WriteWebhookPayload();
|
||||
}
|
||||
|
||||
public sealed class ExecutionContext : RunnerService, IExecutionContext
|
||||
@@ -991,6 +992,24 @@ namespace GitHub.Runner.Worker
|
||||
}
|
||||
}
|
||||
|
||||
public void WriteWebhookPayload()
|
||||
{
|
||||
// Makes directory for event_path data
|
||||
var tempDirectory = HostContext.GetDirectory(WellKnownDirectory.Temp);
|
||||
var workflowDirectory = Path.Combine(tempDirectory, "_github_workflow");
|
||||
Directory.CreateDirectory(workflowDirectory);
|
||||
var gitHubEvent = GetGitHubContext("event");
|
||||
|
||||
// adds the GitHub event path/file if the event exists
|
||||
if (gitHubEvent != null)
|
||||
{
|
||||
var workflowFile = Path.Combine(workflowDirectory, "event.json");
|
||||
Trace.Info($"Write event payload to {workflowFile}");
|
||||
File.WriteAllText(workflowFile, gitHubEvent, new UTF8Encoding(false));
|
||||
SetGitHubContext("event_path", workflowFile);
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeTimelineRecord(Guid timelineId, Guid timelineRecordId, Guid? parentTimelineRecordId, string recordType, string displayName, string refName, int? order)
|
||||
{
|
||||
_mainTimelineId = timelineId;
|
||||
|
||||
Reference in New Issue
Block a user