Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.

Commit c604a60

Browse files
authored
Merge pull request #274 from jodh-intel/actions-for-issue-backlog
action: Add issue to project and move to "In progress" on linked PR
2 parents b91acde + 7dea9b4 commit c604a60

2 files changed

Lines changed: 130 additions & 0 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Copyright (c) 2020 Intel Corporation
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
6+
name: Add newly created issues to the backlog project
7+
8+
on:
9+
issues:
10+
types:
11+
- opened
12+
- reopened
13+
14+
jobs:
15+
add-new-issues-to-backlog:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Install hub
19+
run: |
20+
HUB_ARCH="amd64"
21+
HUB_VER=$(curl -sL "https://api.github.com/repos/github/hub/releases/latest" |\
22+
jq -r .tag_name | sed 's/^v//')
23+
curl -sL \
24+
"https://github.com/github/hub/releases/download/v${HUB_VER}/hub-linux-${HUB_ARCH}-${HUB_VER}.tgz" |\
25+
tar xz --strip-components=2 --wildcards '*/bin/hub' && \
26+
sudo install hub /usr/local/bin
27+
28+
- name: Install hub extension script
29+
run: |
30+
# Clone into a temporary directory to avoid overwriting
31+
# any existing github directory.
32+
pushd $(mktemp -d) &>/dev/null
33+
git clone --single-branch --depth 1 "https://github.com/kata-containers/.github" && cd .github/scripts
34+
sudo install hub-util.sh /usr/local/bin
35+
popd &>/dev/null
36+
37+
- name: Checkout code to allow hub to communicate with the project
38+
uses: actions/checkout@v2
39+
40+
- name: Add issue to issue backlog
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.KATA_GITHUB_ACTIONS_TOKEN }}
43+
run: |
44+
issue=${{ github.event.issue.number }}
45+
46+
project_name="Issue backlog"
47+
project_type="org"
48+
project_column="To do"
49+
50+
hub-util.sh \
51+
add-issue \
52+
"$issue" \
53+
"$project_name" \
54+
"$project_type" \
55+
"$project_column"
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Copyright (c) 2020 Intel Corporation
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
6+
name: Move issues to "In progress" in backlog project when referenced by a PR
7+
8+
on:
9+
pull_request_target:
10+
types:
11+
- opened
12+
- reopened
13+
14+
jobs:
15+
move-linked-issues-to-in-progress:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Install hub
19+
run: |
20+
HUB_ARCH="amd64"
21+
HUB_VER=$(curl -sL "https://api.github.com/repos/github/hub/releases/latest" |\
22+
jq -r .tag_name | sed 's/^v//')
23+
curl -sL \
24+
"https://github.com/github/hub/releases/download/v${HUB_VER}/hub-linux-${HUB_ARCH}-${HUB_VER}.tgz" |\
25+
tar xz --strip-components=2 --wildcards '*/bin/hub' && \
26+
sudo install hub /usr/local/bin
27+
28+
- name: Install hub extension script
29+
run: |
30+
# Clone into a temporary directory to avoid overwriting
31+
# any existing github directory.
32+
pushd $(mktemp -d) &>/dev/null
33+
git clone --single-branch --depth 1 "https://github.com/kata-containers/.github" && cd .github/scripts
34+
sudo install hub-util.sh /usr/local/bin
35+
popd &>/dev/null
36+
37+
- name: Checkout code to allow hub to communicate with the project
38+
uses: actions/checkout@v2
39+
40+
- name: Move issue to "In progress"
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.KATA_GITHUB_ACTIONS_TOKEN }}
43+
run: |
44+
pr=${{ github.event.pull_request.number }}
45+
linked_issue_urls=$(hub-util.sh list-issue-linked-prs |\
46+
grep -v "^\#" |\
47+
grep "/pull/${pr};" |\
48+
cut -d';' -f2 || true)
49+
50+
# PR doesn't have any linked issues
51+
# (it should, but maybe a new user forgot to add a "Fixes #" commit).
52+
[ -z "$linked_issue_urls" ] \
53+
&& echo "::error::No linked issues for PR $pr" \
54+
&& exit 1
55+
56+
project_name="Issue backlog"
57+
project_type="org"
58+
project_column="In progress"
59+
60+
for issue_url in $linked_issue_urls
61+
do
62+
issue=$(echo "$issue_url"| awk -F\/ '{print $NF}' || true)
63+
64+
[ -z "$issue" ] \
65+
&& echo "::error::Cannot determine issue number from $issue_url for PR $pr" \
66+
&& exit 1
67+
68+
# Move the issue to the correct column on the project board
69+
hub-util.sh \
70+
move-issue \
71+
"$issue" \
72+
"$project_name" \
73+
"$project_type" \
74+
"$project_column"
75+
done

0 commit comments

Comments
 (0)