Skip to content

Commit daa8fbf

Browse files
author
rahul-infra
committed
feat!: Updated pr title check and preview release type
1 parent 5b078d7 commit daa8fbf

File tree

3 files changed

+114
-0
lines changed

3 files changed

+114
-0
lines changed

.github/workflows/pr-title.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: 'Validate PR title'
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
main:
8+
name: Validate PR title
9+
runs-on: ubuntu-latest
10+
steps:
11+
# Please look up the latest version from
12+
# https://github.com/amannn/action-semantic-pull-request/releases
13+
- uses: amannn/action-semantic-pull-request@v6.1.1
14+
env:
15+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
with:
17+
# Configure which types are allowed.
18+
# Default: https://github.com/commitizen/conventional-commit-types
19+
types: |
20+
fix
21+
feat
22+
docs
23+
ci
24+
chore
25+
# Configure that a scope must always be provided.
26+
requireScope: false
27+
# Configure additional validation for the subject based on a regex.
28+
# This example ensures the subject starts with an uppercase character.
29+
subjectPattern: ^[A-Z].+$
30+
# If `subjectPattern` is configured, you can use this property to override
31+
# the default error message that is shown when the pattern doesn't match.
32+
# The variables `subject` and `title` can be used within the message.
33+
subjectPatternError: |
34+
The subject "{subject}" found in the pull request title "{title}"
35+
didn't match the configured pattern. Please ensure that the subject
36+
starts with an uppercase character.
37+
# For work-in-progress PRs you can typically use draft pull requests
38+
# from Github. However, private repositories on the free plan don't have
39+
# this option and therefore this action allows you to opt-in to using the
40+
# special "[WIP]" prefix to indicate this state. This will avoid the
41+
# validation of the PR title and the pull request checks remain pending.
42+
# Note that a second check will be reported if this is enabled.
43+
wip: true
44+
# When using "Squash and merge" on a PR with only one commit, GitHub
45+
# will suggest using that commit message instead of the PR title for the
46+
# merge commit, and it's easy to commit this by mistake. Enable this option
47+
# to also validate the commit message for one commit PRs.
48+
validateSingleCommit: false

.github/workflows/terraform.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ on:
1515
- main
1616
- master
1717
jobs:
18+
prTitlecheck:
19+
name: PR title check
20+
if: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.base.ref == 'main' }}
21+
uses: ./.github/workflows/pr-title.yaml
22+
23+
versionPreview:
24+
name: Version Preview
25+
needs: prTitlecheck
26+
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main' }}
27+
uses: ./.github/workflows/version-preview.yaml
28+
1829
preCommitCheck:
1930
name: Terraform Checks
2031
uses: ./.github/workflows/terraform-checks.yaml
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: 'Version Preview'
2+
3+
on:
4+
workflow_call:
5+
6+
defaults:
7+
run:
8+
shell: bash
9+
10+
jobs:
11+
preview:
12+
name: Preview Release
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Preview Next Version
21+
id: preview
22+
uses: cycjimmy/semantic-release-action@v2
23+
with:
24+
semantic_version: 18.0.0
25+
dry_run: true
26+
extra_plugins: |
27+
@semantic-release/changelog@6.0.0
28+
@semantic-release/git@10.0.0
29+
conventional-changelog-conventionalcommits@4.6.3
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Comment PR
34+
uses: actions/github-script@v7
35+
with:
36+
script: |
37+
const published = '${{ steps.preview.outputs.new_release_published }}';
38+
let body = '';
39+
40+
if (published === 'true') {
41+
const releaseType = '${{ steps.preview.outputs.new_release_type }}';
42+
const version = '${{ steps.preview.outputs.new_release_version }}';
43+
const notes = `${{ steps.preview.outputs.new_release_notes }}`;
44+
45+
body = `## Release Preview\n\n**Release Type:** \`${releaseType}\`\n**Next Version:** \`${version}\`\n\n### Release Notes\n${notes}`;
46+
} else {
47+
body = '## Release Preview\n\nNo new release will be created from this PR.';
48+
}
49+
50+
github.rest.issues.createComment({
51+
issue_number: context.issue.number,
52+
owner: context.repo.owner,
53+
repo: context.repo.repo,
54+
body: body
55+
});

0 commit comments

Comments
 (0)