-
Notifications
You must be signed in to change notification settings - Fork 15
67 lines (57 loc) · 2.13 KB
/
target.yml
File metadata and controls
67 lines (57 loc) · 2.13 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
name: Version Target
on: issue_comment
jobs:
check-permission:
runs-on: ubuntu-latest
if: ${{ !github.event.issue.pull_request && contains(github.event.comment.body,'!target') }}
name: Check permission
steps:
# Check for write permission
- name: Check user permission
id: check
uses: scherermichael-oss/action-has-permission@master
with:
required-permission: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Use the output from the `check` step
- name: Run only if user has sufficient permissions
if: steps.check.outputs.has-permission
run: exit 0 #Successful
- name: Run only if user has NOT sufficient permissions
if: "! steps.check.outputs.has-permission"
run: exit 1 #Failed
run-command:
name: Run label check
needs: [check-permission]
runs-on: ubuntu-latest
steps:
- name: Get Version
id: version
run: |
echo "${{ github.event.comment.body }}"
X=`echo "${{ github.event.comment.body }}" | grep -o '!target.*' | awk '{print $2}'`; echo "Target: $X"
if [[ ${X,,} = v* ]]
then
Y="${X,,}"
else
Y="v${X,,}"
fi
echo VERSION="Target : ${Y%.}" >> "$GITHUB_OUTPUT"
- name : "Create label if it doesn't exist"
id: create-label
run: |
if ! gh label list | grep -q "${{ steps.version.outputs.VERSION }}"; then
echo "Label doesn't exist, creating"
gh label create "${{ steps.version.outputs.VERSION }}" --description "A release target." --color 4900CB
fi
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }} #this has to be specified because i'm not checking out the repo
- name : "Assign label to the target issue"
id: assign-label
run: |
gh issue edit ${{ github.event.issue.number }} --add-label "${{ steps.version.outputs.VERSION }}"
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }} #this has to be specified because i'm not checking out the repo