Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(github): Add checkrun support #223

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions docs/services/github.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,84 @@ template.app-deployed: |
Setting this option to `false` is required if you would like to deploy older refs in your default branch.
For more information see the [GitHub Deployment API Docs](https://docs.github.com/en/rest/deployments/deployments?apiVersion=2022-11-28#create-a-deployment).
- If `github.pullRequestComment.content` is set to 65536 characters or more, it will be truncated.

# Supported API

## Status
[Api Docs](https://docs.github.com/en/rest/commits/statuses)

### Example
```yaml
template.app-deployed: |
message: |
Application {{.app.metadata.name}} is now running new version of deployments manifests.
github:
repoURLPath: "{{.app.spec.source.repoURL}}"
revisionPath: "{{.app.status.operationState.syncResult.revision}}"
status:
state: success
label: "continuous-delivery/{{.app.metadata.name}}"
targetURL: "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true"
```
## Deployment
[Api Docs](https://docs.github.com/en/rest/deployments/deployments)
### Example
```yaml
template.app-deployed: |
github:
repoURLPath: "{{.app.spec.source.repoURL}}"
revisionPath: "{{.app.status.operationState.syncResult.revision}}"
deployment:
state: success
environment: production
environmentURL: "https://{{.app.metadata.name}}.example.com"
logURL: "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true"
requiredContexts: []
autoMerge: true
```
## PullRequestComment
[Api Docs](https://docs.github.com/en/rest/issues/comments#create-an-issue-comment)
### Example
```yaml
template.app-deployed: |
github:
repoURLPath: "{{.app.spec.source.repoURL}}"
revisionPath: "{{.app.status.operationState.syncResult.revision}}"
pullRequestComment:
content: |
Application {{.app.metadata.name}} is now running new version of deployments manifests.
See more here: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true
```
## CheckRuns
[Api Docs](https://docs.github.com/en/rest/checks/runs)
### Example

Create new checkrun for the current commit:

```yaml
template.app-deployed: |
github:
repoURLPath: "{{.app.spec.source.repoURL}}"
revisionPath: "{{.app.status.operationState.syncResult.revision}}"
checkRun:
name: "Deployment"
status: "{{if and (eq .app.status.operationState.phase "Succeeded") (eq .app.status.health.status "Healthy")}}"success"{{else}}"failure"{{end}}"
completed_at: "{{ (call .time.Now).Format "2006-01-02T15:04:05Z07:00" }}",
conclusion: "completed"
```

Update existing checkrun:

```yaml
template.app-deployed: |
github:
repoURLPath: "{{.app.spec.source.repoURL}}"
revisionPath: "not used"
checkRun:
name: "Deployment"
id: "{{ (call .repo.GetAppDetails).Helm.GetParameterValueByName "git_check_id" }}"
status: "{{if and (eq .app.status.operationState.phase "Succeeded") (eq .app.status.health.status "Healthy")}}"success"{{else}}"failure"{{end}}"
details_url": "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}?",
completed_at: "{{ (call .time.Now).Format "2006-01-02T15:04:05Z07:00" }}",
conclusion: "completed"
```
Loading
Loading