Skip to content

Commit 5c4edd3

Browse files
Output urls for Jira and Github resources in all actions (#12)
* Output urls for jira and github resources in all actions * add missing closing quotes in yaml example in readme
1 parent 42610d1 commit 5c4edd3

File tree

11 files changed

+125
-52
lines changed

11 files changed

+125
-52
lines changed

check-releasability-status/README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
# Check Releasability Status Action
22

3-
This GitHub Action checks the releasability status of the master branch. If the check was successful, it extracts the version number from its annotation. It's important to note that this action doesn't run the releasability status check itself but rather finds previous runs. The action is designed to be a prerequisite step in a release workflow, ensuring that a version is ready to be released before proceeding.
3+
This GitHub Action checks the releasability status of the master branch. If the check was successful, it extracts the
4+
version number from its annotation. It's important to note that this action doesn't run the releasability status check
5+
itself but rather finds previous runs. The action is designed to be a prerequisite step in a release workflow, ensuring
6+
that a version is ready to be released before proceeding.
47

58
The action is self-contained and uses the `actions/github-script` toolkit to interact with the GitHub Checks API.
69

710
## Prerequisites
811

9-
The action requires that the workflow has `checks: read` permissions for the `GITHUB_TOKEN` to be able to access the Checks API.
12+
The action requires that the workflow has `checks: read` permissions for the `GITHUB_TOKEN` to be able to access the
13+
Checks API.
1014

1115
## Inputs
1216

@@ -25,7 +29,9 @@ The following inputs can be configured for the action:
2529

2630
## Example Usage
2731

28-
Here is an example of how to use this action in a workflow. This workflow can be triggered manually. The first job checks the releasability status and exposes the found version as an output. A second job then consumes this version to perform a subsequent step, such as creating a release.
32+
Here is an example of how to use this action in a workflow. This workflow can be triggered manually. The first job
33+
checks the releasability status and exposes the found version as an output. A second job then consumes this version to
34+
perform a subsequent step, such as creating a release.
2935

3036
```yaml
3137
name: Check Releasability and Use Version
@@ -55,3 +61,4 @@ jobs:
5561
if: needs.check_releasability.outputs.release_version
5662
run: |
5763
echo "The releasable version is ${{ needs.check_releasability.outputs.release_version }}"
64+
```

create-jira-release-ticket/README.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# Create Jira Release Ticket Action
22

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.
3+
This GitHub Action automates the creation of an "Ask for release" ticket in Jira. It is designed to be used in release
4+
workflows to standardize the process of requesting a new software release.
45

56
The action is self-contained and uses a Python script to interact with the Jira API.
7+
68
## Prerequisites
79

810
The action requires that the repository has the `development/kv/data/jira` token configured in vault.
9-
This can be done using the SPEED self-service portal ([more info](https://xtranet-sonarsource.atlassian.net/wiki/spaces/Platform/pages/3553787989/Manage+Vault+Policy+-+SPEED)).
11+
This can be done using the SPEED self-service
12+
portal ([more info](https://xtranet-sonarsource.atlassian.net/wiki/spaces/Platform/pages/3553787989/Manage+Vault+Policy+-+SPEED)).
1013

1114
## Inputs
1215

@@ -34,10 +37,13 @@ The following inputs can be configured for the action:
3437
|---------------------|--------------------------------------------------|
3538
| `ticket_key` | The key of the Jira ticket (e.g., `REL-1234`). |
3639
| `jira_release_name` | The name of the Jira release used by the action. |
40+
| `ticket_url` | The URL of the created Jira ticket. |
41+
| `release_url` | The URL of the Jira release page. |
3742

3843
## Example Usage
3944

40-
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.
45+
Here is an example of how to use this action in a workflow. This job will be triggered manually and will create a Jira
46+
release ticket using the provided inputs and secrets from HashiCorp Vault.
4147

4248
```yaml
4349
name: Create Release Ticket
@@ -49,7 +55,7 @@ env:
4955
on:
5056
workflow_dispatch:
5157
inputs:
52-
version:
58+
version:
5359
description: 'Version'
5460
required: true
5561
default: '1.0.0'
@@ -101,7 +107,10 @@ jobs:
101107
jira_release_name: ${{ github.event.inputs.jira_release }}
102108
sonarlint_changelog: ${{ github.event.inputs.sonarlint_changelog }}
103109

104-
- name: Echo Ticket Key and Release Name
110+
- name: Echo Ticket Details
105111
run: |
106-
echo "The created Jira ticket key is ${{ steps.create_ticket.outputs.ticket_key }}"
107-
echo "The Jira release name used is ${{ steps.create_ticket.outputs.jira_release_name }}"
112+
echo "Ticket Key: ${{ steps.create_ticket.outputs.ticket_key }}"
113+
echo "Ticket URL: ${{ steps.create_ticket.outputs.ticket_url }}"
114+
echo "Release Name: ${{ steps.create_ticket.outputs.jira_release_name }}"
115+
echo "Release URL: ${{ steps.create_ticket.outputs.release_url }}"
116+
```

create-jira-release-ticket/action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ outputs:
5555
jira_release_name:
5656
description: 'The name of the Jira release found or used by the script.'
5757
value: ${{ steps.run_python_script.outputs.jira_release_name }}
58+
ticket_url:
59+
description: 'The URL of the created Jira ticket.'
60+
value: ${{ steps.run_python_script.outputs.ticket_url }}
61+
release_url:
62+
description: 'The URL of the Jira release page.'
63+
value: ${{ steps.run_python_script.outputs.release_url }}
5864

5965
runs:
6066
using: "composite"

create-jira-release-ticket/create_release_ticket.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,13 @@ def main():
212212
eprint(f" Ticket Key: {ticket.key}")
213213
eprint(f" Release Name: {release_notes_info.name}")
214214
eprint(f" Ticket URL: {ticket.permalink()}")
215+
eprint(f" Release URL: {release_notes_info.url}")
215216
eprint("=" * 50)
216217

217218
print(f"ticket_key={ticket.key}")
218219
print(f"jira_release_name={release_notes_info.name}")
220+
print(f"ticket_url={ticket.permalink()}")
221+
print(f"release_url={release_notes_info.url}")
219222

220223

221224
if __name__ == "__main__":

publish-github-release/README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
# Publish GitHub Release Action
22

3-
This GitHub Action automates the creation of a GitHub Release. It can generate release notes by fetching the details directly from a Jira release version, or it can use release notes provided directly as an input.
4-
If not publishing a draft release, the action will wait for the release workflow to complete before reporting its status.
3+
This GitHub Action automates the creation of a GitHub Release. It can generate release notes by fetching the details
4+
directly from a Jira release version, or it can use release notes provided directly as an input.
5+
If not publishing a draft release, the action will wait for the release workflow to complete before reporting its
6+
status.
57

68
This action uses the GitHub CLI to create the release and a Python script to interact with the Jira API.
79

810
## Prerequisites
911

10-
To fetch release notes from Jira, the action requires that the repository has the `development/kv/data/jira` token configured in vault.
11-
This can be done using the SPEED self-service portal ([more info](https://xtranet-sonarsource.atlassian.net/wiki/spaces/Platform/pages/3553787989/Manage+Vault+Policy+-+SPEED)).
12+
To fetch release notes from Jira, the action requires that the repository has the `development/kv/data/jira` token
13+
configured in vault.
14+
This can be done using the SPEED self-service
15+
portal ([more info](https://xtranet-sonarsource.atlassian.net/wiki/spaces/Platform/pages/3553787989/Manage+Vault+Policy+-+SPEED)).
1216

13-
The action also requires a `github_token` with `contents: write` permissions to create the release. The default `${{ github.token }}` is usually sufficient.
17+
The action also requires a `github_token` with `contents: write` permissions to create the release. The default
18+
`${{ github.token }}` is usually sufficient.
1419

1520
## Inputs
1621

@@ -39,7 +44,8 @@ The following inputs can be configured for the action:
3944

4045
## Example Usage
4146

42-
Here is an example of how to use this action in a workflow. This job can be triggered manually to publish a new release, with release notes generated from a specified Jira version.
47+
Here is an example of how to use this action in a workflow. This job can be triggered manually to publish a new release,
48+
with release notes generated from a specified Jira version.
4349

4450
```yaml
4551
name: Publish New Release
@@ -88,3 +94,4 @@ jobs:
8894

8995
- name: Print Release URL
9096
run: echo "Successfully published release at ${{ steps.publish.outputs.release_url }}"
97+
```

release-jira-version/README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
# Release Jira Version Action
22

3-
This GitHub Action automates releasing a version in Jira and then creating a new, subsequent version. It is useful for end-of-release-cycle workflows.
3+
This GitHub Action automates releasing a version in Jira and then creating a new, subsequent version. It is useful for
4+
end-of-release-cycle workflows.
45

56
## How It Works
67

7-
1. **Finds a Version**: It searches for a Jira version matching the `jira_release_name` input within the specified `project_key`.
8-
2. **Releases It**: It marks that version as "released" in Jira, setting the release date to the current day.
9-
3. **Creates the Next Version**:
8+
1. **Finds a Version**: It searches for a Jira version matching the `jira_release_name` input within the specified
9+
`project_key`.
10+
2. **Releases It**: It marks that version as "released" in Jira, setting the release date to the current day.
11+
3. **Creates the Next Version**:
1012
- If you provide a `new_version_name`, it creates a new version with that exact name.
11-
- If you don't, it attempts to increment the last number of the `jira_release_name` (e.g., `1.5.2` becomes `1.5.3`) and creates a new version with the incremented name.
13+
- If you don't, it attempts to increment the last number of the `jira_release_name` (e.g., `1.5.2` becomes `1.5.3`)
14+
and creates a new version with the incremented name.
1215

1316
## Prerequisites
1417

1518
The action requires that the repository has the `development/kv/data/jira` token configured in vault.
16-
This can be done using the SPEED self-service portal ([more info](https://xtranet-sonarsource.atlassian.net/wiki/spaces/Platform/pages/3553787989/Manage+Vault+Policy+-+SPEED)).
19+
This can be done using the SPEED self-service
20+
portal ([more info](https://xtranet-sonarsource.atlassian.net/wiki/spaces/Platform/pages/3553787989/Manage+Vault+Policy+-+SPEED)).
1721

18-
The [Jira API user](https://sonarsource.atlassian.net/jira/people/712020:9dcffe4d-55ee-4d69-b5d1-535c6dbd9cc4) must have the project role `Administrators` for the target project to manage releases.
22+
The [Jira API user](https://sonarsource.atlassian.net/jira/people/712020:9dcffe4d-55ee-4d69-b5d1-535c6dbd9cc4) must
23+
have the project role `Administrators` for the target project to manage releases.
1924

2025
## Inputs
2126

@@ -36,7 +41,8 @@ The [Jira API user](https://sonarsource.atlassian.net/jira/people/712020:9dcffe4
3641

3742
## Example Usage
3843

39-
This example demonstrates a manually triggered workflow that releases the provided version and creates a new one in the `SONARIAC` project.
44+
This example demonstrates a manually triggered workflow that releases the provided version and creates a new one in the
45+
`SONARIAC` project.
4046

4147
```yaml
4248
name: Release Jira Version

update-analyzer/README.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
# Update Analyzer Action
22

3-
This GitHub Action automates the process of updating an analyzer's version within SonarQube or SonarCloud. It checks out the respective product repository, modifies the `build.gradle` file with the new version, and opens a pull request with the changes.
3+
This GitHub Action automates the process of updating an analyzer's version within SonarQube or SonarCloud. It checks out
4+
the respective product repository, modifies the `build.gradle` file with the new version, and opens a pull request with
5+
the changes.
46

5-
The action determines whether to target SonarQube (`sonar-enterprise`) or SonarCloud (`sonarcloud-core`) based on the prefix of the provided `ticket` number (`SONAR-` or `SC-`).
7+
The action determines whether to target SonarQube (`sonar-enterprise`) or SonarCloud (`sonarcloud-core`) based on the
8+
prefix of the provided `ticket` number (`SONAR-` or `SC-`).
69

710
## Prerequisites
811

9-
The `github-token` provided to the action must have the following permissions for the target repository (e.g., `SonarSource/sonar-enterprise`):
10-
* `contents: write`
11-
* `pull-requests: write`
12+
The `github-token` provided to the action must have the following permissions for the target repository (e.g.,
13+
`SonarSource/sonar-enterprise`):
1214

13-
An example PR how to request a token with those permissions can be found [here](https://github.com/SonarSource/re-terraform-aws-vault/pull/6693).
15+
* `contents: write`
16+
* `pull-requests: write`
17+
18+
An example PR how to request a token with those permissions can be
19+
found [here](https://github.com/SonarSource/re-terraform-aws-vault/pull/6693).
1420

1521
## Inputs
1622

@@ -25,7 +31,6 @@ An example PR how to request a token with those permissions can be found [here](
2531
| `reviewers` | A comma-separated list of GitHub usernames to request a review from (e.g., `user1,user2`). | `false` | |
2632
| `body` | The body of the pull request. | `false` | |
2733

28-
2934
## Outputs
3035

3136
| Output | Description |
@@ -34,7 +39,9 @@ An example PR how to request a token with those permissions can be found [here](
3439

3540
## Example Usage
3641

37-
Here is an example of how to use this action in a workflow. This workflow can be triggered manually (`workflow_dispatch`) and uses a secret to provide the required token. The second job demonstrates how to use the `pr-url` output.
42+
Here is an example of how to use this action in a workflow. This workflow can be triggered manually (
43+
`workflow_dispatch`) and uses a secret to provide the required token. The second job demonstrates how to use the
44+
`pr-url` output.
3845

3946
```yaml
4047
# .github/workflows/update-my-analyzer.yml
@@ -65,7 +72,7 @@ jobs:
6572
with:
6673
secrets: |
6774
development/github/token/SonarSource-sonar-php-release-automation token | GITHUB_TOKEN;
68-
75+
6976
- name: Update analyzer and create PR
7077
id: update_step
7178
uses: SonarSource/release-github-actions/update-analyzer@master
@@ -84,4 +91,5 @@ jobs:
8491
steps:
8592
- name: Echo the PR URL
8693
run: |
87-
echo "Pull request created at: ${{ needs.update-analyzer.outputs.pull_request_url }}"
94+
echo "Pull request created at: ${{ needs.update-analyzer.outputs.pull_request_url }}"
95+
```

update-integration-tickets/README.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22

33
This GitHub Action automates the process of finding and updating Jira integration tickets.
44

5-
The action finds both a SonarQube (SQS) integration ticket and a SonarCloud (SC) integration ticket by searching for tickets linked to a specified release ticket. It can then optionally update the `fixVersions` field of the found SQS ticket. If updating the `fixVersions` fails (e.g., due to a non-existent version), it will issue a warning without failing the action.
5+
The action finds both a SonarQube (SQS) integration ticket and a SonarCloud (SC) integration ticket by searching for
6+
tickets linked to a specified release ticket. It can then optionally update the `fixVersions` field of the found SQS
7+
ticket. If updating the `fixVersions` fails (e.g., due to a non-existent version), it will issue a warning without
8+
failing the action.
69

710
## Prerequisites
811

912
The action requires that the repository has the `development/kv/data/jira` token configured in vault.
10-
This can be done using the SPEED self-service portal ([more info](https://xtranet-sonarsource.atlassian.net/wiki/spaces/Platform/pages/3553787989/Manage+Vault+Policy+-+SPEED)).
13+
This can be done using the SPEED self-service
14+
portal ([more info](https://xtranet-sonarsource.atlassian.net/wiki/spaces/Platform/pages/3553787989/Manage+Vault+Policy+-+SPEED)).
1115

1216
## Inputs
1317

@@ -23,14 +27,17 @@ This can be done using the SPEED self-service portal ([more info](https://xtrane
2327

2428
## Outputs
2529

26-
| Output | Description |
27-
|------------------|--------------------------------------------------------------------|
28-
| `sqs_ticket_key` | The key of the SQS integration ticket that was found. |
29-
| `sc_ticket_key` | The key of the SC integration ticket that was found. |
30+
| Output | Description |
31+
|------------------|-------------------------------------------------------|
32+
| `sqs_ticket_key` | The key of the SQS integration ticket that was found. |
33+
| `sc_ticket_key` | The key of the SC integration ticket that was found. |
34+
| `sqs_ticket_url` | The URL of the SQS integration ticket that was found. |
35+
| `sc_ticket_url` | The URL of the SC integration ticket that was found. |
3036

3137
## Example Usage
3238

33-
Here is an example of how to use this action in a workflow. This job will be triggered manually, find the linked SQS and SC tickets, and update the SQS ticket's fix versions.
39+
Here is an example of how to use this action in a workflow. This job will be triggered manually, find the linked SQS and
40+
SC tickets, and update the SQS ticket's fix versions.
3441

3542
```yaml
3643
name: Update Integration Tickets
@@ -71,7 +78,10 @@ jobs:
7178
release_ticket_key: ${{ github.event.inputs.release_ticket }}
7279
sqs_fix_versions: ${{ github.event.inputs.fix_versions }}
7380

74-
- name: Echo Found Ticket Keys
81+
- name: Echo Found Ticket Keys and URLs
7582
run: |
7683
echo "Found SQS integration ticket: ${{ steps.integration_update.outputs.sqs_ticket_key }}"
84+
echo "SQS ticket URL: ${{ steps.integration_update.outputs.sqs_ticket_url }}"
7785
echo "Found SC integration ticket: ${{ steps.integration_update.outputs.sc_ticket_key }}"
86+
echo "SC ticket URL: ${{ steps.integration_update.outputs.sc_ticket_url }}"
87+
```

update-integration-tickets/action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ outputs:
3535
sc_ticket_key:
3636
description: 'The key of the found SC integration ticket.'
3737
value: ${{ steps.run_python_script.outputs.sc_ticket_key }}
38+
sqs_ticket_url:
39+
description: 'The URL of the found SQS integration ticket.'
40+
value: ${{ steps.run_python_script.outputs.sqs_ticket_url }}
41+
sc_ticket_url:
42+
description: 'The URL of the found SC integration ticket.'
43+
value: ${{ steps.run_python_script.outputs.sc_ticket_url }}
3844

3945
runs:
4046
using: "composite"

update-integration-tickets/update_integration_tickets.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
"""
55
This script finds SQS and SC integration tickets linked to a given release ticket,
6-
optionally updates the SQS ticket's fix versions, and returns both keys.
6+
optionally updates the SQS ticket's fix versions, and returns both keys and URLs.
77
"""
88

99
import argparse
@@ -23,7 +23,7 @@ def eprint(*args, **kwargs):
2323

2424
# noinspection DuplicatedCode
2525
def get_jira_instance(use_sandbox=False):
26-
"""Initializes and returns a JIRA client instance."""
26+
"""Initializes and returns a JIRA client instance and the server URL."""
2727
jira_user = os.environ.get('JIRA_USER')
2828
jira_token = os.environ.get('JIRA_TOKEN')
2929

@@ -36,7 +36,7 @@ def get_jira_instance(use_sandbox=False):
3636

3737
try:
3838
jira_client = JIRA(jira_url, basic_auth=(jira_user, jira_token))
39-
return jira_client
39+
return jira_client, jira_url
4040
except JIRAError as e:
4141
eprint(f"Error: JIRA authentication failed. Status: {e.status_code}, Response: {e.text}")
4242
sys.exit(1)
@@ -93,7 +93,7 @@ def main():
9393

9494
args = parser.parse_args()
9595

96-
jira = get_jira_instance(args.use_sandbox)
96+
jira, jira_url = get_jira_instance(args.use_sandbox)
9797

9898
try:
9999
eprint(f"Fetching release ticket '{args.release_ticket_key}' to find linked issues...")
@@ -108,9 +108,16 @@ def main():
108108

109109
update_sqs_fix_versions(jira, sqs_ticket_key, args.sqs_fix_versions)
110110

111+
# Construct browse URLs
112+
base_url = jira_url.rstrip('/')
113+
sqs_ticket_url = f"{base_url}/browse/{sqs_ticket_key}"
114+
sc_ticket_url = f"{base_url}/browse/{sc_ticket_key}"
115+
111116
# Output for the GitHub Action
112117
print(f"sqs_ticket_key={sqs_ticket_key}")
113118
print(f"sc_ticket_key={sc_ticket_key}")
119+
print(f"sqs_ticket_url={sqs_ticket_url}")
120+
print(f"sc_ticket_url={sc_ticket_url}")
114121

115122

116123
if __name__ == "__main__":

0 commit comments

Comments
 (0)