Skip to content

Commit 9fce28a

Browse files
tuning
Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
1 parent 3592006 commit 9fce28a

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
# This workflow can be used to trigger a rebuild of checks for a certain PR.
2+
#
3+
# Automatic triggering is based on PR labeled event.
4+
# The workflow will check if the new label is "rebuild".
5+
# It triggers up to 3 check runs taken from the PR and triggers all their jobs again, independent
6+
# of the previous status. (3 is an arbitrary number, it was just necessary to have more than one in
7+
# case there are different relevant workflows, e.g. build and codeql. This could be limited to
8+
# checks marked as "required" or "failed", but it seems better to trigger all).
9+
# The label "rebuild" is removed after the rebuild is triggered.
10+
#
11+
# It can be triggered manually, referencing a PR number (this is mainly for testing purposes).
112
name: Rebuild PR
213

314
on:
@@ -13,7 +24,7 @@ on:
1324
description: 'Label to trigger rebuild'
1425
required: false
1526
default: 'rebuild'
16-
27+
1728
# grant permission
1829
# - actions:write to allow rerun
1930
# - PR:write to allow removing the label
@@ -26,32 +37,34 @@ env:
2637
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2738
PR_NUMBER: ${{ github.event.number || inputs.pr }}
2839
LABEL: ${{ github.event.label.name || inputs.label }}
40+
BASE: ${{ github.event.pull_request.base.repo.full_name || github.event.repository.full_name }}
2941

3042
jobs:
3143
rebuild:
3244
runs-on: ubuntu-latest
3345
steps:
3446
- name: Info
3547
env:
36-
GITHUB_EVENT: ${{ toJson(github.event) }}
48+
GITHUB: ${{ toJson(github) }}
3749
run: |
38-
echo "$GITHUB_EVENT"
39-
50+
echo "$GITHUB"
51+
4052
- name: Checkout
41-
if: github.head_ref == ''
53+
if: ${{ github.head_ref == '' && env.LABEL == 'rebuild' }}
4254
uses: actions/checkout@v4
4355

4456
- name: Checkout merge
45-
if: github.head_ref != ''
57+
if: ${{ github.head_ref != '' && env.LABEL == 'rebuild' }}
4658
uses: actions/checkout@v4
4759
with:
4860
ref: refs/pull/${{github.event.pull_request.number}}/merge
4961

5062
- name: List Jobs
63+
if: ${{ env.LABEL == 'rebuild' }}
5164
run: |
5265
echo "Label: ${{ env.LABEL }}"
5366
echo "PR: ${{ env.PR_NUMBER }}"
54-
NUMBER=$(gh pr checks ${{ env.PR_NUMBER }} -R holgerfriedrich/openhab-core|grep -v "^rebuild"| sed -E 's#.*/([0-9]+)/job/([0-9]+)#\1#'|grep -ve '[[:alpha:]]'|sort -nu|head -n3|xargs|tr '\n' ' ')
67+
NUMBER=$(gh pr checks ${{ env.PR_NUMBER }} -R ${{ env.BASE }}|grep -v "^rebuild"| sed -E 's#.*/([0-9]+)/job/([0-9]+)#\1#'|grep -ve '[[:alpha:]]'|sort -nu|head -n3|xargs|tr '\n' ' ')
5568
echo "Number of last 3 check jobs: $NUMBER"
5669
echo "NUMBER=$NUMBER">>$GITHUB_ENV
5770

0 commit comments

Comments
 (0)