-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from netodevel/feat/create-ga
feat: #0000 - Adds initial commit
- Loading branch information
Showing
4 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: "Commit Lint" | ||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
- development | ||
- staging | ||
types: | ||
- opened | ||
- reopened | ||
- labeled | ||
- unlabeled | ||
- edited | ||
- synchronize | ||
jobs: | ||
custom_test: | ||
runs-on: ubuntu-latest | ||
name: We test it locally with act | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
token: ${{ secrets.PAT }} | ||
fetch-depth: 0 | ||
- name: Conventional Commits Checker | ||
uses: ./ # Uses an action in the root directory | ||
id: commits-check | ||
with: | ||
target-branch: ${{ github.event.pull_request.base.ref }} | ||
current-branch: ${{ github.event.pull_request.head.ref }} | ||
- name: Get the Result | ||
run: echo "${{ steps.commits-check.outputs.commit-checker }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Base image | ||
FROM alpine:latest | ||
|
||
RUN apk add --no-cache \ | ||
bash \ | ||
ca-certificates \ | ||
curl \ | ||
git | ||
|
||
COPY entrypoint.sh /entrypoint.sh | ||
|
||
RUN chmod +x /entrypoint.sh | ||
|
||
ENTRYPOINT ["/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# action.yaml | ||
name: 'Conventional Commits Checker' | ||
description: 'Check that all pull request commits are following conventional commits' | ||
inputs: | ||
target-branch: | ||
description: 'target branch' | ||
required: true | ||
default: 'main' | ||
current-branch: | ||
description: 'current-branch' | ||
required: true | ||
default: 'main' | ||
outputs: | ||
commit-checker: | ||
description: 'true or false' | ||
runs: | ||
using: docker | ||
image: Dockerfile | ||
args: | ||
- ${{ inputs.target-branch }} | ||
- ${{ inputs.current-branch }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
git config --global --add safe.directory /github/workspace | ||
|
||
# Define the branch names | ||
main_branch=main=$1 | ||
|
||
echo $1 | ||
echo $2 | ||
|
||
# Get all commit messages from the feature branch that are not in the main branch | ||
commits=($(git log --pretty="%s EON" origin/$2 ^origin/$1)) | ||
|
||
pattern="(feat|fix|ci|chore|docs|test|style|refactor): +#([0-9]+) -.{1,}$" | ||
|
||
# Loop through the array and create other structure data | ||
commits_struct=() | ||
for commit in "${commits[@]}"; do | ||
if [ $commit != "EON" ]; then | ||
commit_msg+=" $commit" | ||
fi | ||
if [ $commit == "EON" ]; then | ||
commits_struct+=("${commit_msg}") | ||
commit_msg="" | ||
fi | ||
done | ||
|
||
all_commits_ok="true" | ||
echo "| commit | status" | ||
for msg in "${commits_struct[@]}"; do | ||
if [[ $msg =~ $pattern ]]; then | ||
echo "$msg | ok" | ||
else | ||
echo "$msg | invalid" | ||
all_commits_ok="false" | ||
fi | ||
echo "--" | ||
done | ||
|
||
if [ $all_commits_ok == "true" ]; then | ||
echo "commit-checker=true" >>$GITHUB_OUTPUT | ||
exit 0 | ||
else | ||
echo "commit-checker=false" >>$GITHUB_OUTPUT | ||
exit 1 | ||
fi |