Skip to content

[WIP] 🏃 Verify Emoji with GH actions #470

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

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 8 additions & 0 deletions .github/pr-checks.workflow
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
workflow "PR Checks" {
on = "pull_request"
resolves = ["verify-emoji"]
}

action "verify-emoji" {
uses = "./hack/release/"
}
11 changes: 11 additions & 0 deletions hack/release/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM alpine

LABEL com.github.actions.name="KubeBuilder PR Emoji"
LABEL com.github.actions.name="Verify that KubeBuilder release notes emoji are present on the PR"
LABEL com.github.actions.icon="git-pull-request"
LABEL com.github.actions.color="blue"

COPY common.sh /common.sh
COPY verify-emoji.sh /verify-emoji.sh

ENTRYPOINT ["/verify-emoji.sh"]
1 change: 1 addition & 0 deletions hack/release/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ cr_minor_pattern=":sparkles:|$(printf "\xe2\x9c\xa8")"
cr_patch_pattern=":bug:|$(printf "\xf0\x9f\x90\x9b")"
cr_docs_pattern=":book:|$(printf "\xf0\x9f\x93\x96")"
cr_other_pattern=":running:|$(printf "\xf0\x9f\x8f\x83")"
cr_all_pattern="${cr_major_pattern}|${cr_minor_pattern}|${cr_patch_pattern}|${cr_docs_pattern}|${cr_other_pattern}"

# cr::symbol-type-raw turns :xyz: and the corresponding emoji
# into one of "major", "minor", "patch", "docs", "other", or
Expand Down
22 changes: 22 additions & 0 deletions hack/release/verify-emoji.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -eu
set -o pipefail

pr_title=$(jq '.pull_request.title' < ${GITHUB_EVENT_PATH})

read pr_prefix rest <<<${pr_title}

source "$(dirname ${BASH_SOURCE})/common.sh"

pr_type=$(cr::symbol-type ${pr_prefix})

if [[ ${pr_type} == "unknown" ]]; then
echo "You must specify an emoji at the beginning of the PR to indicate what kind of change this is."
echo "Valid emoji: ${cr_all_pattern}."
echo "See VERSIONING.md for more information."
exit 1
fi

echo "PR is a ${pr_type} change (${pr_prefix})."
exit 0