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(dogfood): use cancel-in-progress/path-change #1831

Merged
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
7 changes: 4 additions & 3 deletions .tekton/doc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ kind: PipelineRun
metadata:
name: doc-generation
annotations:
pipelinesascode.tekton.dev/task: "[git-clone]"
pipelinesascode.tekton.dev/max-keep-runs: "2"
pipelinesascode.tekton.dev/on-cel-expression: |
event == "pull_request" && "docs/***".pathChanged()
pipelinesascode.tekton.dev/cancel-in-progress: "true"
pipelinesascode.tekton.dev/on-event: "pull_request"
pipelinesascode.tekton.dev/on-path-change: "[docs/***]"
pipelinesascode.tekton.dev/on-target-branch: "main"
spec:
params:
- name: repo_url
Expand Down
1 change: 1 addition & 0 deletions .tekton/generate-coverage-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ metadata:
annotations:
pipelinesascode.tekton.dev/task: "[git-clone]"
pipelinesascode.tekton.dev/max-keep-runs: "2"
pipelinesascode.tekton.dev/cancel-in-progress: "true"
pipelinesascode.tekton.dev/on-cel-expression: |
event == "push" && target_branch == "main" && ("***/*.go".pathChanged() || "config/***".pathChanged() || ".tekton/generate-coverage-release.yaml".pathChanged())
spec:
Expand Down
6 changes: 4 additions & 2 deletions .tekton/go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ metadata:
annotations:
pipelinesascode.tekton.dev/task: "[git-clone]"
pipelinesascode.tekton.dev/max-keep-runs: "2"
pipelinesascode.tekton.dev/on-cel-expression: |
event == "pull_request" && "***/*.go".pathChanged()
pipelinesascode.tekton.dev/cancel-in-progress: "true"
pipelinesascode.tekton.dev/on-event: "pull_request"
pipelinesascode.tekton.dev/on-target-branch: "main"
pipelinesascode.tekton.dev/on-path-change: "[***/*.go]"
spec:
params:
- name: repo_url
Expand Down
1 change: 1 addition & 0 deletions .tekton/linter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ metadata:
pipelinesascode.tekton.dev/on-event: "[push, pull_request]"
pipelinesascode.tekton.dev/on-target-branch: "[*]"
pipelinesascode.tekton.dev/max-keep-runs: "2"
pipelinesascode.tekton.dev/cancel-in-progress: "true"
pipelinesascode.tekton.dev/task: "[git-clone]"
spec:
params:
Expand Down
1 change: 1 addition & 0 deletions .tekton/release-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ metadata:
pipelinesascode.tekton.dev/on-target-branch: "[refs/tags/*]"
pipelinesascode.tekton.dev/task: "[.tekton/tasks/goreleaser.yaml]"
pipelinesascode.tekton.dev/task-1: "[git-clone]"
pipelinesascode.tekton.dev/cancel-in-progress: "true"
pipelinesascode.tekton.dev/max-keep-runs: "2"
spec:
params:
Expand Down
60 changes: 23 additions & 37 deletions docs/content/docs/guide/policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,30 @@
title: Policy on actions
weight: 50
---
# Policy on Pipelines-as-Code actions

Pipelines-as-Code has the concepts of Policy to let you control an action allowed
to be executed by a set of users belonging to a Team on an Organisation as
defined on GitHub or other Git Providers (only GitHub and Gitea is supported at
the moment).
# Policy on Pipelines-as-Code Actions

## List of actions supported
Pipelines-as-Code uses policies to control which actions can be performed by
users who belong to specific teams within an organization, as defined on GitHub
or other supported Git providers (currently GitHub and Gitea).

* `pull_request` - This action is triggering the CI on Pipelines-as-Code,
specifying a team will only allow the members of the team to trigger the CI
and will not allow other members regadless if they are Owners or Collaborators
of the repository or the Organization. The OWNERS file is still taken into
account and will as well allow the members of the OWNERS file to trigger the
CI.
* `ok_to_test` - This action will let a user belonging to the allowed team to
issue a `/ok-to-test` comment on a Pull Request to trigger the CI on
Pipelines-as-Code, this let running the CI on Pull Request contributed by a
non collaborator of the repository or the organisation. This apply to the
`/test` and `/retest` commands as well. This take precedence on the
`pull_request` action.
## Supported Actions

## Configuring the Policy on the Repository CR
* `pull_request` - This action triggers the CI in Pipelines-as-Code. Specifying
a team restricts the ability to trigger CI to members of that team, regardless
of whether they are repository or organization owners or
collaborators. However, members listed in the `OWNERS` file are still
permitted to trigger the CI.

To configure the Policy on the Repository CR you need to add the following to the setting of the Repository CR:
* `ok_to_test` - This action allows users who are members of the specified team
to trigger the CI for a pull request by commenting `/ok-to-test`. This enables
CI to run on pull requests submitted by contributors who are not collaborators
of the repository or organization. It also applies to `/test` and `/retest`
commands. This action takes precedence over the `pull_request` action.

## Configuring Policies in the Repository CR

To set up policies in the Repository CR, include the following configuration:

```yaml
apiVersion: "pipelinesascode.tekton.dev/v1alpha1"
Expand All @@ -43,21 +42,8 @@ spec:
- ci-users
```

Users in `ci-admins` team will be able to let other users run the CI on the pull
request and users in `ci-users` team will be able to run the CI on their own
pull request.

## Configuring teams on GitHub

You will need to configure the GitHub Apps on your organisation to use this
feature.

See the documentation on GitHub to configure the teams:

<https://docs.github.com/en/organizations/organizing-members-into-teams/about-teams>

## Configuring teams on Gitea
In this example:

Teams on Gitea are configured on the Organization level. No documentation is
available but you can look at the GitHub documentation to get an idea of how to
configure it.
* Members of the `ci-admins` team can authorize other users to run the CI on
pull requests.
* Members of the `ci-users` team can run CI on their own pull requests.
Loading