Skip to content

Commit 8adb386

Browse files
authored
Merge pull request #4 from pagopa/release-action
feat: Release action
2 parents 202f5a9 + 71aa72c commit 8adb386

File tree

3 files changed

+129
-0
lines changed

3 files changed

+129
-0
lines changed

.github/workflows/pr-title.yml

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

.github/workflows/release.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Release
2+
3+
on:
4+
# Trigger the workflow on push or pull request,
5+
# but only for the main branch
6+
push:
7+
branches:
8+
- main
9+
paths-ignore:
10+
- 'CODEOWNERS'
11+
- '**.md'
12+
- '.**'
13+
workflow_dispatch:
14+
inputs:
15+
logLevel:
16+
description: 'Log level'
17+
required: true
18+
default: 'warning'
19+
type: choice
20+
options:
21+
- info
22+
- warning
23+
- debug
24+
25+
jobs:
26+
release:
27+
name: Release
28+
runs-on: ubuntu-latest
29+
30+
steps:
31+
- name: Checkout
32+
id: checkout
33+
uses: actions/checkout@v2
34+
with:
35+
persist-credentials: false
36+
fetch-depth: 0
37+
38+
- name: Release
39+
id: release
40+
uses: cycjimmy/semantic-release-action@v2
41+
with:
42+
semantic_version: 18.0.0
43+
extra_plugins: |
44+
@semantic-release/[email protected]
45+
@semantic-release/[email protected]
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
49+
- name: Log in to the Container registry
50+
id: docker_login
51+
if: steps.release.outputs.new_release_published == 'true'
52+
uses: docker/login-action@v2
53+
with:
54+
registry: ghcr.io
55+
username: ${{ github.actor }}
56+
password: ${{ secrets.GITHUB_TOKEN }}
57+
58+
- name: Build and push Docker image
59+
id: docker_build_push
60+
if: steps.release.outputs.new_release_published == 'true'
61+
uses: docker/build-push-action@v3
62+
with:
63+
context: .
64+
push: true
65+
tags: |
66+
ghcr.io/${{ github.repository }}:latest
67+
ghcr.io/${{ github.repository }}:v${{ steps.release.outputs.new_release_version }}
68+
labels: |
69+
maintainer=https://pagopa.it
70+
org.opencontainers.image.source=https://github.com/${{ github.repository }}

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ In the repository two github actions are already provided:
6868
* Within **prod_w** set two **Environment protection rules** as shown in the screenshot below:
6969
![](docs/protection-rules-and-secrets.png)
7070

71+
## Releases
72+
73+
New releases are created every time PR are merged with main. A github action is responsible to create the release and it relires on the title of the PR as described in the [official repository](https://github.com/cycjimmy/semantic-release-action)
74+
7175

7276
## Referencees
7377

0 commit comments

Comments
 (0)