Skip to content

Instantly share code, notes, and snippets.

@greut
Last active October 23, 2024 10:55
Show Gist options
  • Save greut/14a432021bb47459ed1f793a2b5093ad to your computer and use it in GitHub Desktop.
Save greut/14a432021bb47459ed1f793a2b5093ad to your computer and use it in GitHub Desktop.
GitHub commit statuses from Argo Workflow
---
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
name: github-notify-template
spec:
arguments:
parameters:
- name: repository_full_name
- name: commit_sha
- name: secret_name
templates:
- name: notify
inputs:
parameters:
- name: repository_full_name
- name: commit_sha
- name: secret_name
volumes:
- name: github-secret
secret:
secretName: "{{inputs.parameters.secret_name}}"
container:
image: "ghcr.io/supportpal/github-gh-cli"
command: [sh, -e, -c]
volumeMounts:
- name: github-secret
mountPath: /secret/github
args:
- >-
case "{{workflow.status}}" in
"Running")
state=pending
;;
"Succeeded")
state=success
;;
"Failed")
state=failure
;;
*)
state=error
;;
esac;
gh auth login --with-token < /secret/github/pat;
gh api --method POST
/repos/{{inputs.parameters.repository_full_name}}/statuses/{{inputs.parameters.commit_sha}}
-f "state=$state"
-f "description=CI: {{workflow.status}}"
-f "target_url=https://argo-workflows.example.org/workflows/{{workflow.namespace}}/{{workflow.name}}"
-f "context=ci"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment