Skip to content

Commit b064b86

Browse files
SONARIAC-2092 Add "Create REL ticket" Github Action (#1)
* Add Create Release Ticket action * remove unecessary package from requirements * fix Dockerfile paths * run python script directly * fix action repo checkout * remove unecessary files * set correct action ref * set correct action ref v2 * switch to self contained action * fix typo * add readme * fix typo in action * fix typo in readme * fix review issues * update input description in example * remove unecessary comment * add job name to example * fix review issues * refactor get_jira_release_notes_info * fix typo * update readme * move log to correct place * fix review issues * fix atlassian prod url
1 parent 30d92d7 commit b064b86

File tree

6 files changed

+578
-0
lines changed

6 files changed

+578
-0
lines changed

.gitignore

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
### Python template
2+
# Byte-compiled / optimized / DLL files
3+
__pycache__/
4+
*.py[cod]
5+
*$py.class
6+
7+
# C extensions
8+
*.so
9+
10+
# Distribution / packaging
11+
.Python
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
wheels/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.nox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
*.py,cover
51+
.hypothesis/
52+
.pytest_cache/
53+
cover/
54+
55+
# Translations
56+
*.mo
57+
*.pot
58+
59+
# Django stuff:
60+
*.log
61+
local_settings.py
62+
db.sqlite3
63+
db.sqlite3-journal
64+
65+
# Flask stuff:
66+
instance/
67+
.webassets-cache
68+
69+
# Scrapy stuff:
70+
.scrapy
71+
72+
# Sphinx documentation
73+
docs/_build/
74+
75+
# PyBuilder
76+
.pybuilder/
77+
target/
78+
79+
# Jupyter Notebook
80+
.ipynb_checkpoints
81+
82+
# IPython
83+
profile_default/
84+
ipython_config.py
85+
86+
# pyenv
87+
# For a library or package, you might want to ignore these files since the code is
88+
# intended to run in multiple environments; otherwise, check them in:
89+
# .python-version
90+
91+
# pipenv
92+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
94+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
95+
# install all needed dependencies.
96+
#Pipfile.lock
97+
98+
# poetry
99+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
100+
# This is especially recommended for binary packages to ensure reproducibility, and is more
101+
# commonly ignored for libraries.
102+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
103+
#poetry.lock
104+
105+
# pdm
106+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
107+
#pdm.lock
108+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
109+
# in version control.
110+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
111+
.pdm.toml
112+
.pdm-python
113+
.pdm-build/
114+
115+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
116+
__pypackages__/
117+
118+
# Celery stuff
119+
celerybeat-schedule
120+
celerybeat.pid
121+
122+
# SageMath parsed files
123+
*.sage.py
124+
125+
# Environments
126+
.env
127+
.venv
128+
env/
129+
venv/
130+
ENV/
131+
env.bak/
132+
venv.bak/
133+
134+
# Spyder project settings
135+
.spyderproject
136+
.spyproject
137+
138+
# Rope project settings
139+
.ropeproject
140+
141+
# mkdocs documentation
142+
/site
143+
144+
# mypy
145+
.mypy_cache/
146+
.dmypy.json
147+
dmypy.json
148+
149+
# Pyre type checker
150+
.pyre/
151+
152+
# pytype static type analyzer
153+
.pytype/
154+
155+
# Cython debug symbols
156+
cython_debug/
157+
158+
/tools/tools.iml
159+
/.idea/

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
# release-github-actions
22

33
A centralized collection of reusable GitHub Actions designed to streamline and automate every stage of the analyzer release process. This repository serves as a versatile toolbox, offering modular automations to eliminate manual, repetitive steps and reduce friction across squads managing analyzer projects. Whether standardizing changelog generation, automating version bumps, handling release publishing, or coordinating cross-repository tasks, these actions help teams back away from cumbersome workflows and focus more on code quality. Pick and combine the automations best suited for your analyzer’s unique release requirements, and easily extend the toolbox to cover new scenarios as they arise.
4+
5+
## Available Actions
6+
7+
* [**Create Jira Release Ticket**](create-jira-release-ticket/README.md): Automates the creation of an "Ask for release" ticket in Jira.

create-jira-release-ticket/README.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Create Jira Release Ticket Action
2+
3+
This GitHub Action automates the creation of an "Ask for release" ticket in Jira. It is designed to be used in release workflows to standardize the process of requesting a new software release.
4+
5+
The action is self-contained and uses a Python script to interact with the Jira API.
6+
## Prerequisites
7+
8+
The action requires that the repository needs to have the `development/kv/data/jira` token configured in vault.
9+
This can done using the SPEED self-service portal ([more info](https://xtranet-sonarsource.atlassian.net/wiki/spaces/Platform/pages/3553787989/Manage+Vault+Policy+-+SPEED)).
10+
11+
## Inputs
12+
13+
The following inputs can be configured for the action:
14+
15+
| Input | Description | Required | Default |
16+
|------------------------|--------------------------------------------------------------------------------------------------------------------|----------|---------|
17+
| `jira_user` | The Jira user (email) for authentication. | `true` | |
18+
| `jira_token` | The Jira API token for authentication. | `true` | |
19+
| `project_key` | The project key (e.g., `SONARIAC`). | `true` | |
20+
| `project_name` | The display name of the project (e.g., `SonarIaC`). Will be used as the prefix of the resulting release ticket. | `true` | |
21+
| `version` | The new version string being released (e.g., `1.2.3`). | `true` | |
22+
| `short_description` | A brief description of the release. | `true` | |
23+
| `targeted_product` | The targeted product version (e.g., `11.0`). | `true` | |
24+
| `sq_compatibility` | The SonarQube compatibility version (e.g., `2025.3`). | `true` | |
25+
| `use_sandbox` | Set to `false` to use the Jira production server. | `false` | `true` |
26+
| `documentation_status` | The status of the release documentation. | `false` | `N/A` |
27+
| `rule_props_changed` | Whether rule properties have changed (`Yes` or `No`). | `false` | `No` |
28+
| `jira_release_name` | The specific Jira release version to use. If omitted and there is only one unreleased version it will released it. | `false` | `''` |
29+
| `sonarlint_changelog` | The SonarLint changelog content. | `false` | `''` |
30+
31+
## Outputs
32+
33+
| Output | Description |
34+
|--------------|------------------------------------------------|
35+
| `ticket_key` | The key of the jira ticket (e.g., `REL-1234`). |
36+
37+
## Example Usage
38+
39+
Here is an example of how to use this action in a workflow. This job will be triggered manually and will create a Jira release ticket using the provided inputs and secrets from HashiCorp Vault.
40+
41+
```yaml
42+
name: Create Release Ticket
43+
44+
# Define environment variables for project-specific settings
45+
env:
46+
PROJECT_KEY: 'SONARIAC'
47+
PROJECT_NAME: 'SonarIaC'
48+
49+
on:
50+
workflow_dispatch:
51+
inputs:
52+
version:
53+
description: 'Version'
54+
required: true
55+
default: '1.0.0'
56+
short_description:
57+
description: 'Short Description'
58+
required: true
59+
targeted_product:
60+
description: 'Targeted Product'
61+
required: true
62+
sq_compatibility:
63+
description: 'SonarQube Compatibility'
64+
required: true
65+
jira_release:
66+
description: 'Jira release version'
67+
required: false
68+
sonarlint_changelog:
69+
description: 'SonarLint changelog content'
70+
required: false
71+
72+
jobs:
73+
create_release_ticket:
74+
name: Create release ticket
75+
runs-on: ubuntu-latest
76+
permissions:
77+
contents: read
78+
id-token: write
79+
80+
steps:
81+
- name: Get Jira Credentials from Vault
82+
id: secrets
83+
uses: SonarSource/vault-action-wrapper@v3
84+
with:
85+
secrets: |
86+
development/kv/data/jira user | JIRA_USER;
87+
development/kv/data/jira token | JIRA_TOKEN;
88+
89+
- name: Create Jira Release Ticket
90+
id: create_ticket
91+
uses: SonarSource/release-github-actions/.github/actions/create-jira-release-ticket
92+
with:
93+
jira_user: ${{ fromJSON(steps.secrets.outputs.vault).JIRA_USER }}
94+
jira_token: ${{ fromJSON(steps.secrets.outputs.vault).JIRA_TOKEN }}
95+
project_key: ${{ env.PROJECT_KEY }}
96+
project_name: ${{ env.PROJECT_NAME }}
97+
version: ${{ github.event.inputs.version }}
98+
short_description: ${{ github.event.inputs.short_description }}
99+
targeted_product: ${{ github.event.inputs.targeted_product }}
100+
sq_compatibility: ${{ github.event.inputs.sq_compatibility }}
101+
jira_release_name: ${{ github.event.inputs.jira_release }}
102+
sonarlint_changelog: ${{ github.event.inputs.sonarlint_changelog }}
103+
104+
- name: Echo Ticket Key
105+
run: echo "The created Jira ticket key is ${{ steps.create_ticket.outputs.ticket_key }}"

create-jira-release-ticket/action.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: 'Create Jira Release Ticket'
2+
description: 'Creates a Jira release ticket.'
3+
author: 'SonarSource'
4+
5+
inputs:
6+
jira_user:
7+
description: 'Jira user for authentication'
8+
required: true
9+
jira_token:
10+
description: 'Jira API token for authentication'
11+
required: true
12+
project_key:
13+
description: 'The key of the project (e.g., SONARIAC)'
14+
required: true
15+
project_name:
16+
description: 'The display name of the project (e.g., SonarIaC)'
17+
required: true
18+
version:
19+
description: 'The version being released (e.g., 11.44.2)'
20+
required: true
21+
short_description:
22+
description: 'A short description for the release'
23+
required: true
24+
targeted_product:
25+
description: 'The targeted product version (e.g., 11.0)'
26+
required: true
27+
sq_compatibility:
28+
description: 'SonarQube compatibility version (e.g., 2025.3)'
29+
required: true
30+
use_sandbox:
31+
description: "Use the sandbox server instead of the production Jira."
32+
required: false
33+
default: 'true'
34+
documentation_status:
35+
description: 'Status of the documentation'
36+
required: false
37+
default: 'N/A'
38+
rule_props_changed:
39+
description: 'Whether rule properties have changed'
40+
required: false
41+
default: 'No'
42+
jira_release_name:
43+
description: 'The specific Jira release version to use.'
44+
required: false
45+
default: ''
46+
sonarlint_changelog:
47+
description: 'The SonarLint changelog content.'
48+
required: false
49+
default: ''
50+
51+
outputs:
52+
ticket_key:
53+
description: 'The key of the created Jira ticket (e.g., REL-123)'
54+
value: ${{ steps.run_python_script.outputs.ticket_key }}
55+
56+
runs:
57+
using: "composite"
58+
steps:
59+
- name: Set up Python
60+
uses: actions/setup-python@v5
61+
with:
62+
python-version: '3.8'
63+
64+
- name: Install dependencies
65+
shell: bash
66+
run: pip install -r ${{ github.action_path }}/requirements.txt
67+
68+
- name: Run Python Script to Create Ticket
69+
id: run_python_script
70+
shell: bash
71+
run: |
72+
SANDBOX_FLAG=""
73+
if [[ "${{ inputs.use_sandbox }}" == "true" ]]; then
74+
SANDBOX_FLAG="--use-sandbox"
75+
fi
76+
77+
TICKET_KEY=$(python ${{ github.action_path }}/create_release_ticket.py \
78+
--project-key="${{ inputs.project_key }}" \
79+
--project-name="${{ inputs.project_name }}" \
80+
--version="${{ inputs.version }}" \
81+
--short-description="${{ inputs.short_description }}" \
82+
--targeted-product="${{ inputs.targeted_product }}" \
83+
--sq-compatibility="${{ inputs.sq_compatibility }}" \
84+
${SANDBOX_FLAG} \
85+
--documentation-status="${{ inputs.documentation_status }}" \
86+
--rule-props-changed="${{ inputs.rule_props_changed }}" \
87+
--jira-release-name="${{ inputs.jira_release_name }}" \
88+
--sonarlint-changelog="${{ inputs.sonarlint_changelog }}"
89+
)
90+
echo "ticket_key=${TICKET_KEY}" >> $GITHUB_OUTPUT
91+
env:
92+
JIRA_USER: ${{ inputs.jira_user }}
93+
JIRA_TOKEN: ${{ inputs.jira_token }}

0 commit comments

Comments
 (0)