Skip to content

Commit

Permalink
Add accepted label and comments
Browse files Browse the repository at this point in the history
* comment on how the workflows are foreseen to be used, namely
  on:
    push:
      branches:
        - "async-v*"

* add back creation of an "accepted" label
  • Loading branch information
Benedikt Volkel committed Apr 5, 2024
1 parent cd67834 commit 2bdc8ab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
22 changes: 9 additions & 13 deletions .github/workflows/async-create-label.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: Create label for new async branch or tag
name: Create label for new async branch

# Foreseen to be used when async-v* branches are pushed in repos that include this workflow
'on':
workflow_call:

Expand All @@ -11,25 +12,20 @@ jobs:
print-labels:
name: Print labels
runs-on: ubuntu-latest
# only run if the created branch or tag starts with the correct pattern, namely "async-"
if: startsWith(github.ref, 'refs/heads/async-v') || startsWith(github.ref, 'refs/tags/async-v')
# only run if the created branch or tag starts with the correct pattern, namely "async-v"
# while the workflow is supposed to only run when branches like async-v* are created (to be filtered in downstream repos),
# we add this check to make sure we don't see any surprises in case filters are forgotten or wrongly implemented
if: startsWith(github.ref, 'refs/heads/async-v')
steps:
- name: Create async branch or tag label
- name: Create async branch label
env:
GH_TOKEN: ${{ github.token }}
ref: ${{ github.ref }}

id: create_label
run: |
# to be on the safe side, check the full ref
case "${ref}" in
refs/heads/*) what_am_i=branch
;;
refs/tags/*) what_am_i=tag
;;
*) echo "Invalid ref ${ref}, abort." && exit 1
;;
esac
# extract only the branch or tag pattern we are really interested in
ref="${ref##*/}"
gh label create --repo "${GITHUB_REPOSITORY}" "${ref}" --description "Concerns ${what_am_i} ${ref}" --color 95C6F0
gh label create --repo "${GITHUB_REPOSITORY}" "${ref}" --description "Request cherry-picks for branch ${ref}" --color 95C6F0
gh label create --repo "${GITHUB_REPOSITORY}" "${ref}" --description "Accepted requests on branch ${ref}" --color 95C6F0
9 changes: 6 additions & 3 deletions .github/workflows/async-update.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: Update when async branch is pushed

# Foreseen to be used when async-v* branches are pushed in repos that include this workflow
'on':
workflow_call:

Expand All @@ -11,7 +12,9 @@ jobs:
update:
name: Update everything
runs-on: ubuntu-latest
# only run if the created branch or tag starts with the correct pattern, namely "async-"
# only run if the created branch or tag starts with the correct pattern, namely "async-v"
# while the workflow is supposed to only run when branches like async-v* are created (to be filtered in downstream repos),
# we add this check to make sure we don't see any surprises in case filters are forgotten or wrongly implemented
if: startsWith(github.ref, 'refs/heads/async-v')
steps:
- name: Update, remove labels, publish table
Expand Down Expand Up @@ -71,8 +74,8 @@ jobs:
if [[ -z "${pr_url}" ]] ; then
echo "Publish this without a linked PR"
else
# remove the label (if any)
gh --repo "${GITHUB_REPOSITORY}" pr edit "${pr_url}" --remove-label "${branch_name}"
# add corresponding "accepted" label
gh --repo "${GITHUB_REPOSITORY}" pr edit "${pr_url}" --add-label "${branch_name}-accepted"
echo "Publish this with linked PR"
fi
# reset the SHAs
Expand Down

0 comments on commit 2bdc8ab

Please sign in to comment.