Skip to content

update-beats

update-beats #213

name: update-beats
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 1-5'
permissions:
contents: read
env:
JOB_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
jobs:
filter:
runs-on: ubuntu-slim
timeout-minutes: 1
outputs:
matrix: ${{ steps.generator.outputs.matrix }}
permissions:
contents: read
steps:
- id: generator
uses: elastic/oblt-actions/elastic/active-branches@v1
update-beats:
permissions:
contents: write
pull-requests: write
needs:
- filter
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.filter.outputs.matrix) }}
steps:
- uses: actions/checkout@v6
with:
submodules: true
ref: ${{ matrix.branch }}
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
- name: Install mage
uses: magefile/mage-action@6f50bbb8ea47d56e62dee92392788acbc8192d0b # v3.1.0
with:
version: v1.14.0
install-only: true
# Note: We can't use updatecli to create the PR because it doesn't handle submodule updates correctly.
# See https://github.com/go-git/go-git/issues/872
- name: Run Updatecli in Apply mode
uses: elastic/oblt-actions/updatecli/run@v1
with:
command: apply --config .ci/updatecli/update-beats.yml --commit=false
version-file: .updatecli-version
env:
BRANCH_NAME: ${{ matrix.branch }}
- name: Export beats versions to environment variables
run: |
echo BEATS_PREVIOUS_VERSION=$(cat /tmp/.beats-previous-version) >> "$GITHUB_ENV"
echo BEATS_NEW_VERSION=$(cat /tmp/.beats-new-version) >> "$GITHUB_ENV"
- name: Create Pull Request
uses: peter-evans/create-pull-request@98357b18bf14b5342f975ff684046ec3b2a07725 # v8.0.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "[${{ matrix.branch }}][Automation] Update elastic/beats to ${{ env.BEATS_NEW_VERSION }}"
title: "[${{ matrix.branch }}][Automation] Update elastic/beats to ${{ env.BEATS_NEW_VERSION }}"
body: |
### What
Update `elastic/beats` to the latest version on branch `${{ matrix.branch }}`.
*Changeset*
* https://github.com/elastic/beats/compare/${{ env.BEATS_PREVIOUS_VERSION }}...${{ env.BEATS_NEW_VERSION }}
branch: update-beats-${{ matrix.branch }}
base: ${{ matrix.branch }}
delete-branch: true
labels: |
automation
skip-changelog
Team:Elastic-Agent-Control-Plane
- if: ${{ failure() }}
uses: elastic/oblt-actions/slack/send@v1
with:
bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
channel-id: "#ingest-notifications"
message: ":traffic_cone: updatecli failed for `${{ github.repository }}@${{ github.ref_name }}`, `@agent-team` please look what's going on <${{ env.JOB_URL }}|here>"