-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaction.yml
More file actions
138 lines (122 loc) · 5.59 KB
/
action.yml
File metadata and controls
138 lines (122 loc) · 5.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: 'Create Jira Release Ticket'
description: 'Creates a Jira release ticket.'
author: 'SonarSource'
inputs:
project-name:
description: 'The display name of the project (e.g., SonarIaC)'
required: true
short-description:
description: 'A short description for the release'
required: true
jira-project-key:
description: 'The key of the project (e.g., SONARIAC). Required if JIRA_PROJECT_KEY env var is not set.'
version:
description: 'The version being released (e.g., 11.44.2), or leave empty to use the release version.'
use-jira-sandbox:
description: "Use the sandbox server instead of the production Jira."
documentation-status:
description: 'Status of the documentation'
default: 'N/A'
rule-props-changed:
description: 'Whether rule properties have changed'
default: 'No'
jira-release-url:
description: 'The URL to the Jira release notes page. Required if JIRA_RELEASE_URL env var is not set. DEPRECATED: use jira-release-id instead.'
default: ''
jira-release-id:
description: 'The ID of the Jira release version.'
default: ''
sonarlint-changelog:
description: 'The SonarLint changelog content.'
default: ''
start-progress:
description: 'Whether to start progress on the release ticket.'
outputs:
release-ticket-key:
description: 'The key of the created Jira ticket (e.g., REL-123)'
value: ${{ steps.run_python_script.outputs.ticket_key }}
release-ticket-url:
description: 'The URL of the created Jira ticket.'
value: ${{ steps.run_python_script.outputs.ticket_url }}
runs:
using: "composite"
steps:
- name: Get Jira Credentials from Vault
id: secrets
uses: SonarSource/vault-action-wrapper@v3
with:
secrets: |
development/kv/data/jira user | JIRA_USER;
development/kv/data/jira token | JIRA_TOKEN;
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.10'
- name: Install dependencies
shell: bash
run: pip install -r ${{ github.action_path }}/requirements.txt
- uses: SonarSource/release-github-actions/get-release-version@v1
if: ${{ !inputs.version }}
- name: Get Jira Release Notes URL
if: ${{ !inputs.jira-release-url && !env.JIRA_RELEASE_URL }}
uses: SonarSource/release-github-actions/get-jira-release-notes@v1
with:
jira-project-key: ${{ inputs.jira-project-key }}
use-jira-sandbox: ${{ inputs.use-jira-sandbox }}
- name: Run Python Script to Create Ticket
id: run_python_script
shell: bash
env:
JIRA_USER: ${{ fromJSON(steps.secrets.outputs.vault).JIRA_USER }}
JIRA_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).JIRA_TOKEN }}
JIRA_URL: "https://sonarsource${{ ((inputs.use-jira-sandbox || env.USE_JIRA_SANDBOX) == 'true') && '-sandbox-608' || '' }}.atlassian.net/"
PROJECT_KEY: ${{ inputs.jira-project-key || env.JIRA_PROJECT_KEY }}
PROJECT_NAME: ${{ inputs.project-name }}
VERSION: ${{ inputs.version || env.RELEASE_VERSION }}
SHORT_DESCRIPTION: ${{ inputs.short-description }}
DOCUMENTATION_STATUS: ${{ inputs.documentation-status }}
RULE_PROPS_CHANGED: ${{ inputs.rule-props-changed }}
JIRA_RELEASE_URL: ${{ inputs.jira-release-url || env.JIRA_RELEASE_URL }}
JIRA_RELEASE_ID: ${{ inputs.jira-release-id || env.JIRA_RELEASE_ID }}
SONARLINT_CHANGELOG: ${{ inputs.sonarlint-changelog }}
run: |
if [[ -z "$PROJECT_KEY" ]]; then
echo "::error::Both jira-project-key input and JIRA_PROJECT_KEY environment variable are missing. One must be provided."
exit 1
fi
if [[ -z "$JIRA_RELEASE_URL" && -z "$JIRA_RELEASE_ID" ]]; then
echo "::error::Both jira-release-url/jira-release-id input and JIRA_RELEASE_URL/JIRA_RELEASE_ID environment variable are missing. One must be provided."
exit 1
fi
if [[ -n "$JIRA_RELEASE_URL" ]]; then
echo "::warning::The jira-release-url input and JIRA_RELEASE_URL env is deprecated. Please use jira-release-id/JIRA_RELEASE_ID instead."
fi
if [[ -n "$JIRA_RELEASE_ID" ]]; then
FIXED_VERSION_ID="$JIRA_RELEASE_ID"
else
# Extract the ID from the URL
FIXED_VERSION_ID=$(echo "$JIRA_RELEASE_URL" | grep -oE '/versions/([0-9]+)' | grep -oE '[0-9]+')
fi
ISSUE_FILTER="${JIRA_URL}issues/?jql=fixVersion%3D${FIXED_VERSION_ID}"
echo "ISSUE_FILTER=$ISSUE_FILTER"
python ${{ github.action_path }}/create_release_ticket.py \
--project-key="$PROJECT_KEY" \
--project-name="$PROJECT_NAME" \
--version="$VERSION" \
--short-description="$SHORT_DESCRIPTION" \
--jira-url="$JIRA_URL" \
--documentation-status="$DOCUMENTATION_STATUS" \
--rule-props-changed="$RULE_PROPS_CHANGED" \
--issue-filter-url="$ISSUE_FILTER" \
--sonarlint-changelog="$SONARLINT_CHANGELOG" >> $GITHUB_OUTPUT
- name: Start Progress on Release Ticket
if: ${{ inputs.start-progress == 'true' }}
uses: SonarSource/release-github-actions/update-release-ticket-status@v1
with:
release-ticket-key: ${{ steps.run_python_script.outputs.ticket_key }}
status: "Start Progress"
- name: Set Env Variables
shell: bash
run: |
echo "RELEASE_TICKET_KEY=${{ steps.run_python_script.outputs.ticket_key }}" >> $GITHUB_ENV
echo "RELEASE_TICKET_URL=${{ steps.run_python_script.outputs.ticket_url }}" >> $GITHUB_ENV