Skip to content

Commit 6b4b612

Browse files
Add repository_dispatch listening
Signed-off-by: Dimitar Dimitrov <[email protected]>
1 parent 554c8a9 commit 6b4b612

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

.github/workflows/update-vendored-mimir-prometheus.yml

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ on:
1414
default: 'main'
1515
type: string
1616

17+
repository_dispatch:
18+
types: [ mimir-prometheus-branch-push ]
19+
1720
permissions:
1821
contents: write
1922
pull-requests: write
@@ -22,10 +25,31 @@ jobs:
2225
update-mimir-prometheus:
2326
runs-on: ubuntu-latest
2427
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+
2549
- name: Check out repository
2650
uses: actions/checkout@v4
2751
with:
28-
ref: ${{ inputs.mimir_branch }}
52+
ref: ${{ steps.branch-names.outputs.mimir_branch }}
2953
token: ${{ secrets.GITHUB_TOKEN }}
3054
fetch-depth: 0
3155
set-safe-directory: '*'
@@ -60,7 +84,7 @@ jobs:
6084
- name: Get mimir-prometheus commit info
6185
id: get-commit-info
6286
env:
63-
MIMIR_PROMETHEUS_BRANCH: ${{ inputs.mimir_prometheus_branch }}
87+
MIMIR_PROMETHEUS_BRANCH: ${{ steps.branch-names.outputs.mimir_prometheus_branch }}
6488
run: |
6589
# Fetch the latest commit hash from the specified branch
6690
COMMIT_HASH=$(git ls-remote https://github.com/grafana/mimir-prometheus.git "${MIMIR_PROMETHEUS_BRANCH}" | cut -f1)
@@ -107,9 +131,10 @@ jobs:
107131
*This PR was automatically created by the [update-mimir-prometheus workflow](https://github.com/grafana/mimir/blob/main/.github/workflows/update-mimir-prometheus.yml)*
108132
109133
### 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 }})
111135
- **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 }}
112137
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 }}
115140
delete-branch: true

0 commit comments

Comments
 (0)