-
Notifications
You must be signed in to change notification settings - Fork 1
58 lines (57 loc) · 2.41 KB
/
note-proposal.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
name: Process Note Proposals
on:
issues:
types: [opened, edited]
env:
GH_TOKEN: ${{ github.token }}
jobs:
process-note-proposal:
if: contains(github.event.issue.labels.*.name, 'note-proposal')
runs-on: ubuntu-latest
steps:
- name: Set up Git repository
uses: actions/checkout@v2
with:
ref: master
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
pip install beautifulsoup4 tqdm ruamel.yaml
- name: Parse issue and create branch
id: parse_issue
run: |
echo "Parsing issue..."
ISSUE_NUMBER=$(echo "${{ github.event.issue.number }}")
BRANCH_NAME="note-proposal-${ISSUE_NUMBER}"
ISSUE_DATE=$(echo "${{ github.event.issue.created_at }}" | cut -d'T' -f1)
echo "##[set-output name=branch_name;]${BRANCH_NAME}"
echo "##[set-output name=issue_date;]${ISSUE_DATE}"
# Create/reset feature branch from master
git checkout -B ${BRANCH_NAME}
- name: Add note to YAML file
run: |
echo "Adding note to YAML file..."
python .github/workflow_scripts/add_note.py "${{ github.event_path }}"
- name: Commit and push changes
run: |
echo "Committing changes..."
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add .
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "Add note from issue #${{ github.event.issue.number }}"
echo "Force pushing changes..."
git push -f origin ${{ steps.parse_issue.outputs.branch_name }}
fi
- name: Comment on issue with PR link
run: |
ISSUE_NUMBER=$(echo "${{ github.event.issue.number }}")
BRANCH_NAME="note-proposal-${ISSUE_NUMBER}"
PR_LINK="https://github.com/${{ github.repository }}/compare/${BRANCH_NAME}?expand=1"
COMMENT_BODY="A new branch has been created with your note proposal. You can edit the text of your issue to update the note. You can create a pull request using the following link: ${PR_LINK}"
gh api -X POST /repos/${{ github.repository }}/issues/${ISSUE_NUMBER}/comments -f body="${COMMENT_BODY}"