Skip to content

update-agent-versions #327

update-agent-versions

update-agent-versions #327

---
name: update-agent-versions
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
jobs:
filter:
runs-on: ubuntu-latest
timeout-minutes: 1
outputs:
matrix: ${{ steps.generator.outputs.matrix }}
steps:
- id: generator
uses: elastic/oblt-actions/elastic/active-branches@v1
with:
exclude-branches: "7.17"
update_versions:
runs-on: ubuntu-latest
needs: [filter]
permissions:
contents: write
pull-requests: write
strategy:
matrix: ${{ fromJson(needs.filter.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: "${{ matrix.branch }}"
# no depth limit
# so, we can generate snapshot versions based on release branches
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.21
- name: Set git config
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Install mage
uses: magefile/mage-action@v3
with:
version: v1.13.0
install-only: true
- name: Update versions
id: update
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./.github/workflows/bump-agent-versions.sh
- if: ${{ failure() }}
uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d # v2.0.0
with:
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
{
"channel": "#ingest-notifications",
"text": "${{ env.SLACK_MESSAGE }}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "${{ env.SLACK_MESSAGE }}"
}
}
]
}
env:
SLACK_MESSAGE: ":traffic_cone: Elastic Agent version update failed: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
# if a PR was created as a result of this job, we notify on the Slack channel
- if: ${{ startsWith(steps.update.outputs.pr, 'https') }}
uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d # v2.0.0
with:
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
{
"channel": "#ingest-notifications",
"text": "${{ env.SLACK_MESSAGE }}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "${{ env.SLACK_MESSAGE }}"
}
}
]
}
env:
SLACK_MESSAGE: "Update for Elastic Agent versions has been created: ${{ steps.update.outputs.pr }}"