-
-
Notifications
You must be signed in to change notification settings - Fork 6
88 lines (77 loc) · 3.18 KB
/
issue-annotation.yaml
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
name: issue-annotation
on:
issues:
types: [opened, edited]
jobs:
AnnotateIssue:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Parse Criteria or Taxonomy Issue
run: |
echo "${{ github.event.issue.body }}" > new-issue.txt
cat new-issue.txt
GITHUB_LABEL=undefined
if grep -q "RSE-taxonomy" "new-issue.txt"; then
GITHUB_LABEL=taxonomy
elif grep -q "criteria-RSE" "new-issue.txt"; then
GITHUB_LABEL=criteria
fi
if [[ "${GITHUB_LABEL}" == "undefined" ]]; then
printf "This issue is not for taxonomy or criteria items.\n"
exit 1;
fi
echo "GITHUB_LABEL=${GITHUB_LABEL}" >> $GITHUB_ENV
- name: Install Research Software Encyclopedia
run: |
sudo apt-get update && sudo apt-get install -y python3 python3-pip python3-setuptools git
git clone https://github.com/rseng/rse
cd rse
sudo pip3 install .[all]
rse --version
- name: Parse Criteria or Taxonomy
run: |
# rse annotate (criteria|taxonomy) --file (filename) --username (user)
echo "rse annotate ${GITHUB_LABEL} --file new-issue.txt --username ${{ github.event.issue.user.login }}"
rse annotate ${GITHUB_LABEL} --file new-issue.txt --username "${{ github.event.issue.user.login }}"
- name: Checkout New Branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH_AGAINST: "master"
GITHUB_USER: "${{ github.event.issue.user.login }}"
run: |
printf "GitHub Actor: ${GITHUB_ACTOR}\n"
export BRANCH_FROM="annotate/${GITHUB_LABEL}-${GITHUB_USER}-$(date '+%Y-%m-%d/%H-%M-%S')"
git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
# Test if branch exists in remote
BRANCH_EXISTS=$(git ls-remote --heads origin ${BRANCH_FROM})
if [[ -z ${BRANCH_EXISTS} ]]; then
printf "Branch does not exist in remote.\n"
else
printf "Branch already exists in remote.\n"
echo 1
fi
echo "BRANCH_EXISTS=${BRANCH_EXISTS}" >> $GITHUB_ENV
git branch
git checkout -b "${BRANCH_FROM}" || git checkout "${BRANCH_FROM}"
git branch
git config --global user.name "github-actions"
git config --global user.email "github-actions@users.noreply.github.com"
git add database/*
git add docs/*
if git diff-index --quiet HEAD --; then
printf "No changes\n"
else
printf "Changes\n"
git commit -m "Automated deployment to update software database $(date '+%Y-%m-%d')"
git push origin "${BRANCH_FROM}"
fi
MESSAGE="Fixes https://github.com/${GITHUB_REPOSITORY}/issues/${{ github.event.issue.number }}"
echo "PULL_REQUEST_FROM_BRANCH=${BRANCH_FROM}" >> $GITHUB_ENV
echo "PULL_REQUEST_BODY=${MESSAGE}" >> $GITHUB_ENV
- name: Open Pull Request
uses: vsoch/pull-request-action@1.0.12
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PULL_REQUEST_BRANCH: "master"