14
14
default : ' main'
15
15
type : string
16
16
17
+ repository_dispatch :
18
+ types : [ mimir-prometheus-branch-push ]
19
+
17
20
permissions :
18
21
contents : write
19
22
pull-requests : write
@@ -22,10 +25,31 @@ jobs:
22
25
update-mimir-prometheus :
23
26
runs-on : ubuntu-latest
24
27
steps :
28
+ - name : Determine branch names
29
+ id : branch-names
30
+ run : |
31
+ if [ "${{ github.event_name }}" = "repository_dispatch" ]; then
32
+ # For repository_dispatch, use the branch_name from client_payload for mimir_prometheus_branch.
33
+ # The main use case is for weekly branches, so we just use the same branch name here too.
34
+ MIMIR_PROMETHEUS_BRANCH="${{ github.event.client_payload.branch_name }}"
35
+ MIMIR_BRANCH=$MIMIR_PROMETHEUS_BRANCH
36
+ echo "Triggered by repository_dispatch"
37
+ echo "Using mimir-prometheus branch from payload: $MIMIR_PROMETHEUS_BRANCH"
38
+ else
39
+ # For workflow_dispatch, use the input values
40
+ MIMIR_BRANCH="${{ inputs.mimir_branch }}"
41
+ MIMIR_PROMETHEUS_BRANCH="${{ inputs.mimir_prometheus_branch }}"
42
+ echo "Triggered by workflow_dispatch"
43
+ echo "Using input values - mimir branch: $MIMIR_BRANCH, mimir-prometheus branch: $MIMIR_PROMETHEUS_BRANCH"
44
+ fi
45
+
46
+ echo "mimir_branch=$MIMIR_BRANCH" >> $GITHUB_OUTPUT
47
+ echo "mimir_prometheus_branch=$MIMIR_PROMETHEUS_BRANCH" >> $GITHUB_OUTPUT
48
+
25
49
- name : Check out repository
26
50
uses : actions/checkout@v4
27
51
with :
28
- ref : ${{ inputs .mimir_branch }}
52
+ ref : ${{ steps.branch-names.outputs .mimir_branch }}
29
53
token : ${{ secrets.GITHUB_TOKEN }}
30
54
fetch-depth : 0
31
55
set-safe-directory : ' *'
60
84
- name : Get mimir-prometheus commit info
61
85
id : get-commit-info
62
86
env :
63
- MIMIR_PROMETHEUS_BRANCH : ${{ inputs .mimir_prometheus_branch }}
87
+ MIMIR_PROMETHEUS_BRANCH : ${{ steps.branch-names.outputs .mimir_prometheus_branch }}
64
88
run : |
65
89
# Fetch the latest commit hash from the specified branch
66
90
COMMIT_HASH=$(git ls-remote https://github.com/grafana/mimir-prometheus.git "${MIMIR_PROMETHEUS_BRANCH}" | cut -f1)
@@ -107,9 +131,10 @@ jobs:
107
131
*This PR was automatically created by the [update-mimir-prometheus workflow](https://github.com/grafana/mimir/blob/main/.github/workflows/update-mimir-prometheus.yml)*
108
132
109
133
### Details:
110
- - **Source branch/ref**: [`${{ inputs. mimir_prometheus_branch }}`](https://github.com/grafana/mimir-prometheus/tree/${{ inputs .mimir_prometheus_branch }})
134
+ - **Source branch/ref**: [`${{ steps.branch-names.outputs. mimir_prometheus_branch }}`](https://github.com/grafana/mimir-prometheus/tree/${{ steps.branch-names.outputs .mimir_prometheus_branch }})
111
135
- **Commit hash**: [`${{ steps.get-commit-info.outputs.commit_hash }}`](https://github.com/grafana/mimir-prometheus/commit/${{ steps.get-commit-info.outputs.commit_hash }})
136
+ - **Trigger**: ${{ github.event_name }}
112
137
commit-message : Update mimir-prometheus to `${{ steps.get-commit-info.outputs.short_hash }}`
113
- branch : bot/${{ inputs .mimir_branch }}/update-mimir-prometheus-${{ steps.get-commit-info.outputs.short_hash }}-${{ steps.get-commit-info.outputs.timestamp }}
114
- base : ${{ inputs .mimir_branch }}
138
+ branch : bot/${{ steps.branch-names.outputs .mimir_branch }}/update-mimir-prometheus-${{ steps.get-commit-info.outputs.short_hash }}-${{ steps.get-commit-info.outputs.timestamp }}
139
+ base : ${{ steps.branch-names.outputs .mimir_branch }}
115
140
delete-branch : true
0 commit comments