Skip to content

Commit

Permalink
(chore) Only run gitlint on pull requests
Browse files Browse the repository at this point in the history
Because this cause issues with the gitlint running on the main branch
when doing a squash or Merge commit.

Adjust documentation for how to sue headers mentioning that headers are
case sensitive in params.

Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
  • Loading branch information
chmouel committed Nov 18, 2024
1 parent aff3b66 commit 33cc338
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
11 changes: 11 additions & 0 deletions .tekton/linter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,17 @@ spec:
image: registry.access.redhat.com/ubi9/python-312
workingDir: $(workspaces.source.path)
script: |
set -x
if [[ "{{ headers['X-Github-Event'] }}" == "" ]]; then
echo "Not a GitHub event, skipping gitlint"
exit 0
fi
if [[ "{{ headers['X-Github-Event'] }}" != "pull_request" ]]; then
echo "Not a pull request, skipping gitlint"
exit 0
fi
git config --global --add safe.directory $(workspaces.source.path)
git log -1 --format=format:%s |grep -E -q '^Merge branch' && exit 0
pip3 install gitlint
Expand Down
6 changes: 3 additions & 3 deletions docs/content/docs/guide/authoringprs.md
Original file line number Diff line number Diff line change
Expand Up @@ -377,11 +377,11 @@ The expression are CEL expressions so you can as well make some conditional:
if the PR is open the condition then return `true` and the shell script see this
as a valid boolean.

Headers from the payload body can be accessed from the `headers` keyword, for
example
Headers from the payload body can be accessed from the `headers` keyword, note that headers are case sensitive,
for example this will show the GitHub event type for a GitHub event:

```yaml
{{ headers['x-github-event'] }}
{{ headers['X-Github-Event'] }}
```

and then you can do the same conditional or access as described above for the `body` keyword.
Expand Down

0 comments on commit 33cc338

Please sign in to comment.