Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/fix in develop labeler #1410

Merged
merged 5 commits into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/scripts/build_assets/api_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions .github/scripts/build_assets/arg_getters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
6 changes: 5 additions & 1 deletion .github/scripts/in_develop_labeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
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"]
Snailedlt marked this conversation as resolved.
Show resolved Hide resolved

# 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]
Snailedlt marked this conversation as resolved.
Show resolved Hide resolved

print("Issue Line is " + issue_line)
issue_pattern = re.compile(r"\d+")
Expand Down
29 changes: 22 additions & 7 deletions .github/workflows/in_develop_labeler.yml
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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/[email protected]
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/[email protected]
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"
24 changes: 24 additions & 0 deletions .github/workflows/in_develop_labeler_preflight.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
with:
name: pr_num
path: ./pr_num.txt