Skip to content

Commit aa2d900

Browse files
authored
updatecli: create PRs per active branch and refactor slack notifications (#8359)
1 parent 00f81bd commit aa2d900

File tree

3 files changed

+53
-24
lines changed

3 files changed

+53
-24
lines changed

.ci/updatecli/updatecli-bump-vm-images.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# update-cli configuration for automated VM image version bumping
22
---
33
name: Bump vm-images to latest version
4+
pipelineid: 'updatecli-update-vm-images-{{ requiredEnv "BRANCH_NAME" }}'
45

56
scms:
67
githubConfig:
@@ -12,7 +13,7 @@ scms:
1213
repository: '{{ .scm.repository }}'
1314
token: '{{ requiredEnv "GITHUB_TOKEN" }}'
1415
commitusingapi: true
15-
branch: '{{ .scm.branch }}'
16+
branch: '{{ requiredEnv "BRANCH_NAME" }}'
1617
force: false
1718

1819
actions:
@@ -24,8 +25,8 @@ actions:
2425
automerge: false
2526
labels:
2627
- dependencies
27-
- backport-active-all
28-
title: '[Automation] Bump VM Image version to {{ source "latestVersion" }}'
28+
- backport-skip
29+
title: '[{{ requiredEnv "BRANCH_NAME" }}][Automation] Bump VM Image version to {{ source "latestVersion" }}'
2930

3031
sources:
3132
latestVersion:
@@ -43,6 +44,8 @@ conditions:
4344
spec:
4445
command: 'grep -q -v {{ source "latestVersion" }} .buildkite/pipeline.yml #'
4546

47+
# NOTE: if you add a new target file, please update the .mergify.yml file
48+
# to include the new file for the approval and automatic merge
4649
targets:
4750
update-buildkite-pipeline:
4851
name: "Update .buildkite/pipeline.yml"

.github/workflows/bump-vm-images.yml

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ name: bump-vm-images
44
on:
55
workflow_dispatch:
66
schedule:
7-
- cron: "0 10 * * 0"
7+
# Since the CI Agent images are produced weekly on Saturday at 0am UTC
8+
# and we can only bump the version after the images are available
9+
# let's try on Saturday at 12:00 UTC.
10+
- cron: "0 12 * * 6"
811

912
permissions:
1013
contents: read
@@ -13,11 +16,29 @@ env:
1316
JOB_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
1417

1518
jobs:
19+
filter:
20+
runs-on: ubuntu-latest
21+
timeout-minutes: 1
22+
outputs:
23+
matrix: ${{ steps.generator.outputs.matrix }}
24+
permissions:
25+
contents: read
26+
steps:
27+
- id: generator
28+
uses: elastic/oblt-actions/elastic/active-branches@v1
29+
with:
30+
filter-branches: true
31+
1632
bump:
1733
permissions:
1834
contents: write
1935
pull-requests: write
2036
runs-on: ubuntu-latest
37+
needs:
38+
- filter
39+
strategy:
40+
fail-fast: false
41+
matrix: ${{ fromJson(needs.filter.outputs.matrix) }}
2142
steps:
2243
- uses: actions/checkout@v4
2344

@@ -26,26 +47,11 @@ jobs:
2647
command: apply --config .ci/updatecli/updatecli-bump-vm-images.yml --values .ci/updatecli/values.d/scm.yml
2748
env:
2849
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
BRANCH_NAME: ${{ matrix.branch }}
2951

3052
- if: ${{ failure() }}
31-
uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d # v2.0.0
53+
uses: elastic/oblt-actions/slack/send@v1
3254
with:
33-
method: chat.postMessage
34-
token: ${{ secrets.SLACK_BOT_TOKEN }}
35-
payload: |
36-
{
37-
"channel": "#ingest-notifications",
38-
"text": "${{ env.SLACK_MESSAGE }}",
39-
"blocks": [
40-
{
41-
"type": "section",
42-
"text": {
43-
"type": "mrkdwn",
44-
"text": "${{ env.SLACK_MESSAGE }}"
45-
}
46-
}
47-
]
48-
}
49-
env:
50-
#SLACK_MESSAGE: ":traffic_cone: updatecli failed for `${{ github.repository }}@${{ github.ref_name }}`, `@agent-team` please look what's going on <${{ env.JOB_URL }}|here>"
51-
SLACK_MESSAGE: ":traffic_cone: updatecli failed for `${{ github.repository }}@${{ github.ref_name }}`"
55+
bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
56+
channel-id: "#ingest-notifications"
57+
message: ":traffic_cone: updatecli failed for `${{ github.repository }}@${{ github.ref_name }}`, @robots-ci please look what's going on <${{ env.JOB_URL }}|here>"

.mergify.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,26 @@ defaults:
1919
labels:
2020
- "backport"
2121
pull_request_rules:
22+
- name: automatic approval for updatecli pull requests with changes in .buildkite
23+
conditions:
24+
- author=github-actions[bot]
25+
- check-success=buildkite/elastic-agent
26+
- files~=^.buildkite/(pipeline.yml|bk.integration.pipeline.yml)$
27+
- head~=^updatecli_.*
28+
actions:
29+
review:
30+
type: APPROVE
31+
message: Automatically approving mergify
32+
- name: automatic squash and merge with success checks and the files matching the regex .buildkite is modified.
33+
conditions:
34+
- author=github-actions[bot]
35+
- check-success=buildkite/elastic-agent
36+
- files~=^.buildkite/(pipeline.yml|bk.integration.pipeline.yml)$
37+
- head~=^updatecli_.*
38+
- "#approved-reviews-by>=1"
39+
actions:
40+
queue:
41+
name: default
2242
- name: self-assign PRs
2343
conditions:
2444
- -merged

0 commit comments

Comments
 (0)