GhEx.Actions (gh_ex v0.3.4)

Copy Markdown View Source

Convenience functions for the GitHub Actions REST API (workflows and runs).

Thin wrappers over GhEx.REST that return the same {:ok, body, meta} / {:error, reason} shape; opts pass through to Req. A workflow is the numeric workflow id or its file name (for example "ci.yml").

Summary

Functions

Approves a workflow run from a first-time contributor's public fork.

Deletes an Actions artifact. GitHub returns 204 No Content on success.

Deletes all logs for a workflow run. GitHub returns 204 No Content on success.

Triggers a workflow_dispatch event. attrs is the JSON body: ref (required) and optional inputs. Returns a 204 with an empty body on success.

Downloads an artifact archive and returns {:ok, bytes, meta}.

Downloads one job's logs and returns {:ok, text, meta}.

Downloads a workflow run's log archive and returns {:ok, zip_bytes, meta}.

Gets one job from a workflow run.

Gets a workflow by id or file name.

Lists all Actions artifacts in a repository. Use params: [name: ...] to filter.

Lists deployment environments waiting for protection rules on a workflow run.

Returns the deployment review history for a workflow run.

Lists the artifacts produced by one workflow run.

Lists the jobs for a workflow run.

Lists workflow runs in a repository. Use params: for branch, status, event.

Lists the workflows in a repository.

Re-runs failed jobs and their dependent jobs in a workflow run.

Re-runs one job and its dependent jobs.

Approves or rejects a custom deployment protection rule for a workflow run.

Approves or rejects pending deployments for a workflow run.

Auto-paginates repository artifacts into a lazy Stream, unwrapping "artifacts".

Auto-paginates one workflow run's artifacts, unwrapping "artifacts".

Auto-paginates the jobs for a workflow run into a lazy Stream, unwrapping "jobs".

Auto-paginates workflow runs into a lazy Stream, unwrapping "workflow_runs".

Auto-paginates the workflows in a repository into a lazy Stream, unwrapping the "workflows" array on each page (see GhEx.REST.stream/3).

Types

id()

@type id() :: integer() | String.t()

Functions

approve_run(client, owner, repo, run_id, opts \\ [])

@spec approve_run(GhEx.Client.t(), String.t(), String.t(), id(), keyword()) ::
  GhEx.REST.result()

Approves a workflow run from a first-time contributor's public fork.

GitHub returns 201 Created when the approval succeeds.

cancel_run(client, owner, repo, run_id, opts \\ [])

@spec cancel_run(GhEx.Client.t(), String.t(), String.t(), id(), keyword()) ::
  GhEx.REST.result()

Cancels a workflow run.

delete_artifact(client, owner, repo, artifact_id, opts \\ [])

@spec delete_artifact(GhEx.Client.t(), String.t(), String.t(), id(), keyword()) ::
  GhEx.REST.result()

Deletes an Actions artifact. GitHub returns 204 No Content on success.

delete_run_logs(client, owner, repo, run_id, opts \\ [])

@spec delete_run_logs(GhEx.Client.t(), String.t(), String.t(), id(), keyword()) ::
  GhEx.REST.result()

Deletes all logs for a workflow run. GitHub returns 204 No Content on success.

dispatch_workflow(client, owner, repo, workflow, attrs, opts \\ [])

@spec dispatch_workflow(
  GhEx.Client.t(),
  String.t(),
  String.t(),
  id(),
  map(),
  keyword()
) ::
  GhEx.REST.result()

Triggers a workflow_dispatch event. attrs is the JSON body: ref (required) and optional inputs. Returns a 204 with an empty body on success.

download_artifact(client, owner, repo, artifact_id, archive_format, opts \\ [])

@spec download_artifact(
  GhEx.Client.t(),
  String.t(),
  String.t(),
  id(),
  String.t(),
  keyword()
) :: GhEx.REST.result()

Downloads an artifact archive and returns {:ok, bytes, meta}.

GitHub currently supports only the "zip" archive format. Req follows the temporary signed-URL redirect automatically and does not forward credentials when the redirect changes origin. The returned meta describes the final download response.

download_job_logs(client, owner, repo, job_id, opts \\ [])

@spec download_job_logs(GhEx.Client.t(), String.t(), String.t(), id(), keyword()) ::
  GhEx.REST.result()

Downloads one job's logs and returns {:ok, text, meta}.

Req follows GitHub's temporary signed-URL redirect automatically and strips credentials if the redirect changes origin.

download_run_logs(client, owner, repo, run_id, opts \\ [])

@spec download_run_logs(GhEx.Client.t(), String.t(), String.t(), id(), keyword()) ::
  GhEx.REST.result()

Downloads a workflow run's log archive and returns {:ok, zip_bytes, meta}.

Req follows GitHub's temporary signed-URL redirect automatically and strips credentials if the redirect changes origin.

get_artifact(client, owner, repo, artifact_id, opts \\ [])

@spec get_artifact(GhEx.Client.t(), String.t(), String.t(), id(), keyword()) ::
  GhEx.REST.result()

Gets one Actions artifact by id.

get_job(client, owner, repo, job_id, opts \\ [])

@spec get_job(GhEx.Client.t(), String.t(), String.t(), id(), keyword()) ::
  GhEx.REST.result()

Gets one job from a workflow run.

get_run(client, owner, repo, run_id, opts \\ [])

@spec get_run(GhEx.Client.t(), String.t(), String.t(), id(), keyword()) ::
  GhEx.REST.result()

Gets a workflow run.

get_workflow(client, owner, repo, workflow, opts \\ [])

@spec get_workflow(GhEx.Client.t(), String.t(), String.t(), id(), keyword()) ::
  GhEx.REST.result()

Gets a workflow by id or file name.

list_artifacts(client, owner, repo, opts \\ [])

@spec list_artifacts(GhEx.Client.t(), String.t(), String.t(), keyword()) ::
  GhEx.REST.result()

Lists all Actions artifacts in a repository. Use params: [name: ...] to filter.

list_pending_deployments(client, owner, repo, run_id, opts \\ [])

@spec list_pending_deployments(
  GhEx.Client.t(),
  String.t(),
  String.t(),
  id(),
  keyword()
) ::
  GhEx.REST.result()

Lists deployment environments waiting for protection rules on a workflow run.

Each item describes an environment, its protection rules, and whether the authenticated user can approve it.

list_run_approvals(client, owner, repo, run_id, opts \\ [])

@spec list_run_approvals(GhEx.Client.t(), String.t(), String.t(), id(), keyword()) ::
  GhEx.REST.result()

Returns the deployment review history for a workflow run.

list_run_artifacts(client, owner, repo, run_id, opts \\ [])

@spec list_run_artifacts(GhEx.Client.t(), String.t(), String.t(), id(), keyword()) ::
  GhEx.REST.result()

Lists the artifacts produced by one workflow run.

list_run_jobs(client, owner, repo, run_id, opts \\ [])

@spec list_run_jobs(GhEx.Client.t(), String.t(), String.t(), id(), keyword()) ::
  GhEx.REST.result()

Lists the jobs for a workflow run.

list_runs(client, owner, repo, opts \\ [])

@spec list_runs(GhEx.Client.t(), String.t(), String.t(), keyword()) ::
  GhEx.REST.result()

Lists workflow runs in a repository. Use params: for branch, status, event.

list_workflows(client, owner, repo, opts \\ [])

@spec list_workflows(GhEx.Client.t(), String.t(), String.t(), keyword()) ::
  GhEx.REST.result()

Lists the workflows in a repository.

rerun(client, owner, repo, run_id, opts \\ [])

@spec rerun(GhEx.Client.t(), String.t(), String.t(), id(), keyword()) ::
  GhEx.REST.result()

Re-runs a workflow run.

rerun_failed_jobs(client, owner, repo, run_id, opts \\ [])

@spec rerun_failed_jobs(GhEx.Client.t(), String.t(), String.t(), id(), keyword()) ::
  GhEx.REST.result()

Re-runs failed jobs and their dependent jobs in a workflow run.

Pass json: %{enable_debug_logging: true} in opts to enable debug logging.

rerun_job(client, owner, repo, job_id, opts \\ [])

@spec rerun_job(GhEx.Client.t(), String.t(), String.t(), id(), keyword()) ::
  GhEx.REST.result()

Re-runs one job and its dependent jobs.

Pass json: %{enable_debug_logging: true} or json: %{enable_debugger: true} in opts when needed.

review_deployment_protection_rule(client, owner, repo, run_id, attrs, opts \\ [])

@spec review_deployment_protection_rule(
  GhEx.Client.t(),
  String.t(),
  String.t(),
  id(),
  map(),
  keyword()
) :: GhEx.REST.result()

Approves or rejects a custom deployment protection rule for a workflow run.

attrs must contain environment_name, a state of "approved" or "rejected", and a comment. GitHub Apps can review only their own custom protection rules.

review_pending_deployments(client, owner, repo, run_id, attrs, opts \\ [])

@spec review_pending_deployments(
  GhEx.Client.t(),
  String.t(),
  String.t(),
  id(),
  map(),
  keyword()
) :: GhEx.REST.result()

Approves or rejects pending deployments for a workflow run.

attrs must contain environment_ids, a state of "approved" or "rejected", and a comment.

stream_artifacts(client, owner, repo, opts \\ [])

@spec stream_artifacts(GhEx.Client.t(), String.t(), String.t(), keyword()) ::
  Enumerable.t()

Auto-paginates repository artifacts into a lazy Stream, unwrapping "artifacts".

stream_run_artifacts(client, owner, repo, run_id, opts \\ [])

@spec stream_run_artifacts(GhEx.Client.t(), String.t(), String.t(), id(), keyword()) ::
  Enumerable.t()

Auto-paginates one workflow run's artifacts, unwrapping "artifacts".

stream_run_jobs(client, owner, repo, run_id, opts \\ [])

@spec stream_run_jobs(GhEx.Client.t(), String.t(), String.t(), id(), keyword()) ::
  Enumerable.t()

Auto-paginates the jobs for a workflow run into a lazy Stream, unwrapping "jobs".

stream_runs(client, owner, repo, opts \\ [])

@spec stream_runs(GhEx.Client.t(), String.t(), String.t(), keyword()) ::
  Enumerable.t()

Auto-paginates workflow runs into a lazy Stream, unwrapping "workflow_runs".

stream_workflows(client, owner, repo, opts \\ [])

@spec stream_workflows(GhEx.Client.t(), String.t(), String.t(), keyword()) ::
  Enumerable.t()

Auto-paginates the workflows in a repository into a lazy Stream, unwrapping the "workflows" array on each page (see GhEx.REST.stream/3).