-
-
Notifications
You must be signed in to change notification settings - Fork 53
60 lines (58 loc) · 2.21 KB
/
new_prefix_pr.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
name: "Register new prefix"
on:
workflow_dispatch:
issues:
types: [ opened ]
jobs:
register:
name: Register new prefix
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.12" ]
steps:
- uses: actions/checkout@v2
- name: Delay to ensure labels are attached
run: sleep 10
- name: Check Issue Labels
id: check_labels
uses: actions/github-script@v6
with:
script: |
const issue = context.payload.issue;
const hasRequiredLabels = issue.labels.some(label => label.name === "New") && issue.labels.some(label => label.name === "Prefix");
core.setOutput("hasRequiredLabels", hasRequiredLabels ? 'true' : 'false');
- name: End Workflow if Labels are Missing
if: steps.check_labels.outputs.hasRequiredLabels == 'false'
run: |
echo "Issue does not have 'New' and 'Prefix' labels. Ending workflow."
exit 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
if: steps.check_labels.outputs.hasRequiredLabels == 'true'
run: pip install -e .[gha]
- name: Update
id: update
if: steps.check_labels.outputs.hasRequiredLabels == 'true'
run: python -m bioregistry.gh.new_prefix --github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Branch
id: create_branch
if: steps.check_labels.outputs.hasRequiredLabels == 'true'
run: |
issue_url="${{ github.event.issue.html_url }}"
issue_number=$(echo "$issue_url" | grep -oE '[0-9]+$')
branch_name="create-pull-request/patch-$issue_number"
echo "::set-output name=branch_name::$branch_name"
- name: Create Pull Request
if: steps.check_labels.outputs.hasRequiredLabels == 'true'
uses: peter-evans/create-pull-request@v3
with:
branch: ${{ steps.create_branch.outputs.branch_name }}
labels: New,Prefix
body: ${{ steps.update.outputs.BR_BODY }}
title: ${{ steps.update.outputs.BR_TITLE }}