Skip to content
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
19 changes: 19 additions & 0 deletions .github/workflows/pr_title-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: Check Pull Request Title

on:
pull_request:
types: [opened, edited]

permissions: {}

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
submodules: recursive
fetch-depth: 0
- uses: ./check-pr-title
13 changes: 13 additions & 0 deletions .scripts/actions/install_committed.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

set -euo pipefail
[ -n "${RUNNER_DEBUG+set}" ] && set -x

ARCH=$(uname -m)
mkdir /tmp/committed

curl -fsSL -o /tmp/committed/committed.tar.gz "https://github.com/crate-ci/committed/releases/download/${COMMITTED_VERSION}/committed-${COMMITTED_VERSION}-${ARCH}-unknown-linux-musl.tar.gz"

tar --directory="/tmp/committed" -zxvf /tmp/committed/committed.tar.gz ./committed
sudo install -m 755 -t /usr/local/bin /tmp/committed/committed
rm -rf /tmp/committed
24 changes: 24 additions & 0 deletions .scripts/local/update_allowed_scopes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

set -euo pipefail

AUTO_GENERATED_COMMENT="autogenerated by .scripts/local/update_allowed_scopes.sh"
LIST_TMP=$(mktemp)

echo "# start:scopes: $AUTO_GENERATED_COMMENT" >> "$LIST_TMP"
echo "allowed_scopes = [" >> "$LIST_TMP"

for ACTION in $(find . -mindepth 2 -name action.yaml -print0 | xargs -0 -n 1 dirname | xargs -n 1 basename | sort); do
echo " \"$ACTION\"," >> "$LIST_TMP"
done

echo "]" >> "$LIST_TMP"
echo -n "# end:scopes" >> "$LIST_TMP"

LIST_CONTENT=$(sed ':a;N;$!ba;s/\n/\\n/g' "$LIST_TMP")
SCOPES_TMP=$(mktemp)

awk -v LIST_CONTENT="$LIST_CONTENT" "/^# start:scopes/{flag=1; print LIST_CONTENT} {if(!flag)print} /# end:scopes/{flag=0;next}" committed.toml > "$SCOPES_TMP"
cp "$SCOPES_TMP" committed.toml

rm "$LIST_TMP" "$SCOPES_TMP"
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ particular step in a workflow.
<!-- start:links: autogenerated by .scripts/local/update_readme_list.sh -->
- [build-container-image](./build-container-image/README.md)
- [build-product-image](./build-product-image/README.md)
- [check-pr-title](./check-pr-title/README.md)
- [detect-changes](./detect-changes/README.md)
- [free-disk-space](./free-disk-space/README.md)
- [publish-helm-chart](./publish-helm-chart/README.md)
Expand Down
23 changes: 23 additions & 0 deletions check-pr-title/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# `check-pr-title`

> Manifest: [check-pr-title/action.yml][check-pr-title]

This action checks that the PR title conforms to rules defined by the committed config file.

## Inputs and Outputs

> [!TIP]
> For descriptions of the inputs and outputs, see the complete [check-pr-title] action.

### Inputs

| Input | Required | Description |
| ------------------- | -------- | ---------------------------------------------------------------------- |
| `config-file` | No | Path to the committed config file. Defaults to `./committed.toml` |
| `committed-version` | No | The committed version used to check the PR title. Defaults to `latest` |

### Outputs

None.

[check-pr-title]: ./action.yaml
30 changes: 30 additions & 0 deletions check-pr-title/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: Check Pull Request Title
description: This action checks that the PR title matches rules defined by the committed config file

inputs:
config-file:
description: Patch to config file, defaults to `./committed.toml`
required: false
default: ./committed.toml
committed-version:
description: The version of committed, defaults to `v1.1.11`.
required: false
default: v1.1.11

runs:
using: composite
steps:
- name: Set up committed
env:
COMMITTED_VERSION: ${{ inputs.committed-version }}
shell: bash
run: "$GITHUB_ACTION_PATH/../.scripts/actions/install_committed.sh"

- name: Check Pull Request Title
env:
PULL_REQUEST_TITLE: ${{ github.event.pull_request.title }}
CONFIG_FILE: ${{ inputs.config-file }}
shell: bash
run: |
echo "$PULL_REQUEST_TITLE" | committed --config "$CONFIG_FILE" --commit-file -
23 changes: 23 additions & 0 deletions committed.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
style = "conventional"
allowed_types = ["refactor", "chore", "feat", "docs", "fix", "ci"]
# Generated using `cargo boil image list --pretty never | jq 'keys'` + boil, patchable
# start:scopes: autogenerated by .scripts/local/update_allowed_scopes.sh
allowed_scopes = [
"build-container-image",
"build-product-image",
"check-pr-title",
"detect-changes",
"free-disk-space",
"publish-helm-chart",
"publish-image",
"publish-image-index-manifest",
"run-integration-test",
"run-openshift-preflight",
"run-pre-commit",
"run-prek",
"send-slack-notification",
"setup-k8s-tools",
"setup-tools",
"shard",
]
# end:scopes