forked from Medsien/release-to-jira
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
89 lines (82 loc) · 2.84 KB
/
action.yml
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
name: Release to JIRA
description: A GitHub action to automatically create releases on JIRA.
author: ulasozguler
branding:
icon: 'edit'
color: 'blue'
inputs:
jira_server:
description: JIRA server
required: true
jira_project:
description: JIRA project
required: true
jira_user:
description: JIRA user
required: true
jira_token:
description: JIRA user token
required: true
jira_release_prefix:
description: A string to apply to the beginning of the github_ref when creating the release on Jira
required: false
runs:
using: composite
steps:
- uses: actions/checkout@v4
# install python
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install python dependencies
shell: bash
working-directory: ${{ github.action_path }}
run: pip install -r requirements.txt
- name: Install GH CLI
shell: bash
run: |
if ! command -v gh &> /dev/null
then
type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y)
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y
fi
- name: Export vars
shell: bash
run: |
if [[ "${{ inputs.jira_release_prefix }}" ]]; then
PREFIX="${{ inputs.jira_release_prefix }}"
else
PREFIX=""
fi
echo "RELEASE_NAME_PREFIX=${PREFIX}" >> $GITHUB_ENV
- name: Get or create Github release
if: ${{ success() }}
shell: bash
working-directory: ${{ github.action_path }}
env:
GH_TOKEN: ${{ github.token }}
run: |
gh api \
--method GET /repos/${{ github.repository }}/releases/tags/${{ github.ref_name }} \
> notes.json \
|| \
gh api \
--method POST /repos/${{ github.repository }}/releases \
-f tag_name='${{ github.ref_name }}' \
-f name='${{ github.ref_name }}' \
-F generate_release_notes=true \
--jq .body > notes.md
- name: Update JIRA
if: ${{ success() }}
shell: bash
working-directory: ${{ github.action_path }}
env:
INPUT_JIRA_SERVER: ${{ inputs.jira_server }}
INPUT_JIRA_PROJECT: ${{ inputs.jira_project }}
INPUT_JIRA_USER: ${{ inputs.jira_user }}
INPUT_JIRA_TOKEN: ${{ inputs.jira_token }}
run: python ./src/main.py