Skip to content

Commit eb7d5d9

Browse files
authored
Merge pull request #21 from t0mk/semantic_release_action
ci: Add GHAs for PR validation and semantic release action
2 parents 86402cd + 678439c commit eb7d5d9

File tree

3 files changed

+123
-0
lines changed

3 files changed

+123
-0
lines changed

.github/workflows/release.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Generate Next Release
2+
# This workflow will generate changelog and release notes.
3+
# Source: https://github.com/terraform-aws-modules/terraform-aws-vpc/blob/master/.github/workflows/release.yml
4+
5+
on:
6+
workflow_dispatch:
7+
8+
jobs:
9+
release:
10+
name: Release
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Install Go
14+
uses: actions/setup-go@v5
15+
with:
16+
go-version: 1.19.x
17+
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Release
24+
uses: cycjimmy/semantic-release-action@v4
25+
with:
26+
semantic_version: 19.0.5
27+
extra_plugins: |
28+
@semantic-release/[email protected]
29+
@semantic-release/[email protected]
30+
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
GIT_AUTHOR_NAME: equinix-labs@auto-commit-workflow
34+
GIT_AUTHOR_EMAIL: [email protected]
35+
GIT_COMMITTER_NAME: equinix-labs@auto-commit-workflow
36+
GIT_COMMITTER_EMAIL: [email protected]
37+
RELEASE_REQUESTER: "@${{ github.event.sender.login }}"

.github/workflows/validate_pr.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: "Validate PR Title"
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- edited
8+
- synchronize
9+
10+
permissions:
11+
pull-requests: write
12+
13+
jobs:
14+
main:
15+
name: Validate PR title
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: amannn/action-semantic-pull-request@v5
19+
id: lint_pr_title
20+
env:
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22+
23+
- uses: marocchino/sticky-pull-request-comment@v2
24+
# When the previous steps fails, the workflow would stop. By adding this
25+
# condition you can continue the execution with the populated error message.
26+
if: always() && (steps.lint_pr_title.outputs.error_message != null)
27+
with:
28+
header: pr-title-lint-error
29+
message: |
30+
Hey there and thank you for opening this pull request! 👋🏼
31+
32+
We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like your proposed title needs to be adjusted.
33+
34+
Details:
35+
36+
```
37+
${{ steps.lint_pr_title.outputs.error_message }}
38+
```
39+
40+
# Delete a previous comment when the issue has been resolved
41+
- if: ${{ steps.lint_pr_title.outputs.error_message == null }}
42+
uses: marocchino/sticky-pull-request-comment@v2
43+
with:
44+
header: pr-title-lint-error
45+
delete: true

.releaserc.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"branches": [
3+
"master"
4+
],
5+
"ci": false,
6+
"plugins": [
7+
[
8+
"@semantic-release/commit-analyzer",
9+
{
10+
"preset": "conventionalcommits"
11+
}
12+
],
13+
[
14+
"@semantic-release/release-notes-generator",
15+
{
16+
"preset": "conventionalcommits"
17+
}
18+
],
19+
[
20+
"@semantic-release/github",
21+
{
22+
"successComment": "This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} :tada:",
23+
"labels": false,
24+
"releasedLabels": false
25+
}
26+
],
27+
[
28+
"@semantic-release/exec",
29+
{
30+
"prepareCmd": "echo -n '${nextRelease.version}' > version && make generate-all"
31+
}
32+
],
33+
[
34+
"@semantic-release/git",
35+
{
36+
"message": "ci: regenerate code for version ${nextRelease.version} triggered by ${process.env.RELEASE_REQUESTER}",
37+
"assets": ["."]
38+
}
39+
]
40+
]
41+
}

0 commit comments

Comments
 (0)