Skip to content

Actions

Describes actions what should be run as reaction to fired trigger.

There are only two differences between these resources:

  • ClusterAction is a cluster wide resource, but Action is namespaced one.
  • sourceOverride section of the Action can refer to any kind of sources whereas ClusterAction can use cluster scoped sources only (ClusterGitRepo).

Actual defaults that will be used instead of omitted fields depend on the values from dynamic controllers' config, so defaults mentioned below are actually defaults of the controller but may be overridden in controllers' configuration.

Below are examples of each resource kind with detailed comments. You see that minimal action resource may look like:

apiVersion: git-events-runner.rs/v1alpha1
kind: Action
metadata:
  name: some-action
  namespace: default
spec:
  actionJob:

and in this case, all defaults will be applied: default images, entrypoints, arguments, etc.

Action

Action
apiVersion: git-events-runner.rs/v1alpha1
kind: Action
metadata:
  name: some-action
  namespace: default
spec:
  # Optional definition of the Job to run to complete this action
  actionJob:
    command: entrypoint.sh
    # Optional list of the worker container arguments
    # Default is CMD of the worker image
    args:
      - ./runme.sh
      - with
      - some
      - parameters
    # Optional action worker image reference
    # Default is `ghcr.io/alex-karpenko/git-events-runner/action-worker`
    # with tag of the current controller version
    actionImage: ghcr.io/alex-karpenko/git-events-runner/action-worker:latest
    # Optional action gitrepo cloner image reference
    # Default is `ghcr.io/alex-karpenko/git-events-runner/gitrepo-cloner`
    # with tag of the current controller version
    clonerImage: ghcr.io/alex-karpenko/git-events-runner/gitrepo-cloner:latest
    # Kubernetes Service account to use for the Job
    # No defaults, so the default namespace service account will be used
    serviceAccount: git-events-runner-action-job
    # Folder to clone repo content to, and this is workdir of the worker container
    # Default is `/action_workdir`
    workdir: /action_workdir
    # Turn on debug in `gitrepo-cloner` container,
    # Sometimes it's useful to facilitate issues investigation during repo cloning
    # Default is `false`
    enableClonerDebug: false
    # By default, `gitrepo-cloner` removes .git folder from the workdir after cloning,
    # to preserve storage space (usually this folder is the largest one) and to hide
    # details about repo from the worker.
    # This option allows access to the .git folder in worker container.
    preserveGitFolder: false
    # Time limit to wait to complete action Job.
    # Incomplete Job will be terminated after this time.
    activeDeadlineSeconds: 3600
    # Optional limit of waiting time before Job will be run in the cluster,
    # if the limit of maximum running jobs is exceeded.
    jobWaitingTimeoutSeconds: 300
    # Time limit to preserve finished action Job in a cluster.
    # Finished Job will be deleted after this time.
    ttlSecondsAfterFinished: 7200
    # Optional additional labels to attach to the Job and Pod template.
    # Action attaches some labels to track Jobs' state and activity,
    # these labels will be added to the existing.
    labels: {}
    # Optional annotations to add to the Job and Pod template.
    annotations: {}
    # Optional affinity definition to add to the Pod template.
    # For details about format, please refet to the official Kubernetes documentation:
    # https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/
    affinity: {}
    # Optional node selector definition to add to the Pod template.
    # For details about format, please refet to the official Kubernetes documentation:
    # https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector
    nodeSelector: {}
    # Optional tolerations definition to add to the Pod template.
    # For details about format, please refet to the official Kubernetes documentation:
    # https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/
    tolerations: []
    # Optional entrypoint of the worker container,
    # Default is ENTRYPOINT of the worker image

  # By using this optional feature, we can substitute repo/commit which triggers this action,
  # by some other predefined repo/commit. This is useful to do when we need to run something
  # not from triggers' repo as reaction to triggers' repo changes.
  # All fields are mandatory if you use this feature.
  sourceOverride:
    # Type of the source,
    # Allowed values: GitRepo, ClusterGitRepo
    kind: GitRepo
    # Name of the source
    name: git-repo-name
    # Reference, which should be used in the overridden source,
    # Allowed keys: branch, tag and commit with corresponding values.
    # These keys are mutually exclusive.
    reference:
      # Use particular branch as reference
      branch: main
      # Use particular tag as reference
      tag: v0.1.0
      # Use exact commit hash as reference
      commit: 92abcd3fc4082ed5e53f12b383e14580b83dcff3

ClusterAction

ClusterAction
apiVersion: git-events-runner.rs/v1alpha1
kind: ClusterAction
metadata:
  name: some-action
spec:
  # Optional definition of the Job to run to complete this action
  actionJob:
    # Optional entrypoint of the worker container,
    # Default is ENTRYPOINT of the worker image
    command: entrypoint.sh
    # Optional list of the worker container arguments
    # Default is CMD of the worker image
    args:
      - ./runme.sh
      - with
      - some
      - parameters
    # Optional action worker image reference
    # Default is `ghcr.io/alex-karpenko/git-events-runner/action-worker`
    # with tag of the current controller version
    actionImage: ghcr.io/alex-karpenko/git-events-runner/action-worker:latest
    # Optional action gitrepo cloner image reference
    # Default is `ghcr.io/alex-karpenko/git-events-runner/gitrepo-cloner`
    # with tag of the current controller version
    clonerImage: ghcr.io/alex-karpenko/git-events-runner/gitrepo-cloner:latest
    # Kubernetes Service account to use for the Job
    # No defaults, so the default namespace service account will be used
    serviceAccount: git-events-runner-action-job
    # Folder to clone repo content to, and this is workdir of the worker container
    # Default is `/action_workdir`
    workdir: /action_workdir
    # Turn on debug in `gitrepo-cloner` container,
    # Sometimes it's useful to facilitate issues investigation during repo cloning
    # Default is `false`
    enableClonerDebug: false
    # By default, `gitrepo-cloner` removes .git folder from the workdir after cloning,
    # to preserve storage space (usually this folder is the largest one) and to hide
    # details about repo from the worker.
    # This option allows access to the .git folder in worker container.
    preserveGitFolder: false
    # Time limit to wait to complete action Job.
    # Incomplete Job will be terminated after this time.
    activeDeadlineSeconds: 3600
    # Optional limit of waiting time before Job will be run in the cluster,
    # if the limit of maximum running jobs is exceeded.
    jobWaitingTimeoutSeconds: 300
    # Time limit to preserve finished action Job in a cluster.
    # Finished Job will be deleted after this time.
    ttlSecondsAfterFinished: 7200
    # Optional additional labels to attach to the Job and Pod template.
    # Action attaches some labels to track Jobs' state and activity,
    # these labels will be added to the existing.
    labels: {}
    # Optional annotations to add to the Job and Pod template.
    annotations: {}
    # Optional affinity definition to add to the Pod template.
    # For details about format, please refet to the official Kubernetes documentation:
    # https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/
    affinity: {}
    # Optional node selector definition to add to the Pod template.
    # For details about format, please refet to the official Kubernetes documentation:
    # https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector
    nodeSelector: {}
    # Optional tolerations definition to add to the Pod template.
    # For details about format, please refet to the official Kubernetes documentation:
    # https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/
    tolerations: []
    # Optional entrypoint of the worker container,
    # Default is ENTRYPOINT of the worker image

  # By using this optional feature, we can substitute repo/commit which triggers this action,
  # by some other predefined repo/commit. This is useful to do when we need to run something
  # not from triggers' repo as reaction to triggers' repo changes.
  # All fields are mandatory if you use this feature.
  sourceOverride:
    # Type of the source,
    # Allowed values: ClusterGitRepo only
    kind: ClusterGitRepo
    # Name of the source
    name: git-repo-name
    # Reference, which should be used in the overridden source,
    # Allowed keys: branch, tag and commit with corresponding values.
    # These keys are mutually exclusive.
    reference:
      # Use particular branch as reference
      branch: main
      # Use particular tag as reference
      tag: v0.1.0
      # Use exact commit hash as reference
      commit: 92abcd3fc4082ed5e53f12b383e14580b83dcff3