1
0
mirror of https://github.com/konpa/devicon.git synced 2025-08-06 22:57:02 +02:00

Bugfix/fix in-develop labeler (#1410)

* fix issue not being labeled with in-develop

* restrict to only run on merge to develop

* Remove Python setup

Co-authored-by: Josélio Júnior <76992016+lunatic-fox@users.noreply.github.com>

---------

Co-authored-by: Josélio Júnior <76992016+lunatic-fox@users.noreply.github.com>
Co-authored-by: David Leal <halfpacho@gmail.com>
This commit is contained in:
Jørgen Kalsnes Hagen
2023-04-26 18:44:36 +02:00
committed by GitHub
parent ed1798836c
commit 70df11eef5
5 changed files with 69 additions and 10 deletions

View File

@@ -180,3 +180,19 @@ def get_issues_by_labels(token: str, labels: List[str]):
issues.extend(issues_only)
return issues
def get_pr_by_number(token: str, pr_num: str):
url = base_url + "pulls/" + pr_num
headers = {
"Authorization": f"token {token}"
}
print(f"Querying the GitHub API for requests")
response = requests.get(url, headers=headers)
if not response:
print(f"Can't query the GitHub API. Status code is {response.status_code}. Message is {response.text}")
sys.exit(1)
pr = response.json()
return pr

View File

@@ -82,7 +82,7 @@ def get_in_develop_labeler_args():
help="The GitHub token to access the GitHub REST API.",
type=str)
parser.add_argument("body",
help="The PR's initial comment by the author AKA the `body` attribute of the `pull_request` API object.",
parser.add_argument("pr_num",
help="The PR's number",
type=str)
return parser.parse_args()

View File

@@ -4,8 +4,12 @@ from build_assets import arg_getters, api_handler
def main():
args = arg_getters.get_in_develop_labeler_args()
try:
#get pr body
pr_body = api_handler.get_pr_by_number(args.token, args.pr_num)["body"]
# find the issue closing line
issue_line = [line for line in args.body.split("\n") if line.startswith("**This PR closes")][0]
print(pr_body.split("\n"))
issue_line = [line for line in pr_body.split("\n") if line.startswith("**This PR closes")][0]
print("Issue Line is " + issue_line)
issue_pattern = re.compile(r"\d+")

View File

@@ -1,12 +1,14 @@
name: Label Issue In Develop
on:
pull_request:
types: [closed]
on:
workflow_run:
workflows: ['On Develop PR Merge']
types:
- completed
jobs:
label:
label_preflight:
name: Label Issue In Develop
runs-on: ubuntu-18.04
if: github.event.pull_request.merged == true
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- uses: actions/checkout@v2
@@ -19,9 +21,22 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r ./.github/scripts/requirements.txt
- name: Download workflow artifact
uses: dawidd6/action-download-artifact@v2.11.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: peek_icons.yml
run_id: ${{ github.event.workflow_run.id }}
- name: Read the pr_num file
id: pr_num_reader
uses: juliangruber/read-file-action@v1.0.0
with:
path: ./pr_num/pr_num.txt
- name: Run in_develop_labeler.py
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
BODY: ${{ github.event.pull_request.body }}
run: python ./.github/scripts/in_develop_labeler.py $TOKEN "$BODY"
PR_NUM: ${{ steps.pr_num_reader.outputs.content }}
run: python ./.github/scripts/in_develop_labeler.py $TOKEN "$PR_NUM"

View File

@@ -0,0 +1,24 @@
name: On Develop PR Merge
on:
pull_request:
types: [closed]
branches: [develop]
jobs:
save_pr_num_in_artifact:
name: Preflight Label Issue In Develop
runs-on: ubuntu-18.04
if: github.event.pull_request.merged == true
steps:
- uses: actions/checkout@v2
- name: Save the PR number in an artifact
shell: bash
env:
PR_NUM: ${{ github.event.number }}
run: echo $PR_NUM > pr_num.txt
- name: Upload the PR number
uses: actions/upload-artifact@v2.2.4
with:
name: pr_num
path: ./pr_num.txt