Skip to content

Commit

Permalink
Add github action to bump stack versions (elastic#10599)
Browse files Browse the repository at this point in the history
The action uses updatecli to automate bump of stack snapshots used for testing.
  • Loading branch information
jsoriano authored and James Valente committed Aug 21, 2024
1 parent 89526bf commit 6642c4f
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,13 @@ updates:
- automation
reviewers:
- "elastic/ecosystem"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"
open-pull-requests-limit: 2
labels:
- automation
reviewers:
- "elastic/ecosystem"
50 changes: 50 additions & 0 deletions .github/workflows/bump-elastic-stack-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
name: Update versions of Elastic Stack dependencies

on:
workflow_dispatch:
schedule:
- cron: '0 1 * * 1-5'
pull_request:
paths:
- .github/updatecli.d/*
- .github/workflows/bump-elastic-stack-version.yml

permissions:
contents: read

jobs:
bump-elastic-stack:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4

- name: Install Updatecli in the runner
uses: updatecli/[email protected] # updatecli v0.80.0

- name: Select diff action
if: ${{ github.event_name == 'pull_request' }}
run: |
echo "UPDATECLI_ACTION=diff" >> $GITHUB_ENV
- name: Select apply action
if: ${{ github.event_name != 'pull_request' }}
run: |
echo "UPDATECLI_ACTION=apply" >> $GITHUB_ENV
- name: Update latest testing 7.x stack version
# --experimental needed for commitusingapi option.
run: updatecli --experimental ${{ env.UPDATECLI_ACTION }} --config .github/workflows/updatecli.d/bump-latest-7x-version.yml --values .github/workflows/updatecli.d/scm.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Update latest testing stack version
# --experimental needed for commitusingapi option.
run: updatecli --experimental ${{ env.UPDATECLI_ACTION }} --config .github/workflows/updatecli.d/bump-latest-snapshot-version.yml --values .github/workflows/updatecli.d/scm.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43 changes: 43 additions & 0 deletions .github/workflows/updatecli.d/bump-latest-7x-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
name: Bump 7.x test version
pipelineid: 'bump-elastic-stack-7x-version'

actions:
default:
title: '[updatecli] Update 7.x snapshot to {{ source "latest7xSnapshot" }}'
kind: github/pullrequest
scmid: default
spec:
labels:
- automation
- dependency

scms:
default:
kind: github
spec:
owner: '{{ .scm.owner }}'
repository: '{{ .scm.repository }}'
user: '{{ requiredEnv "GITHUB_ACTOR" }}'
token: '{{ requiredEnv "GITHUB_TOKEN" }}'
commitusingapi: true
branch: main

sources:
latest7xSnapshot:
name: Get latest 7.x snapshot
kind: json
spec:
file: https://storage.googleapis.com/artifacts-api/snapshots/7.17.json
key: .version

targets:
update-7x-version:
name: '[updatecli] Update 7.x snapshot to {{ source "latest7xSnapshot" }}'
kind: file
sourceid: latest7xSnapshot
scmid: default
spec:
file: '.buildkite/pipeline.schedule-daily.yml'
matchpattern: '(STACK_VERSION:) 7\.[^\s]*\.[^\s]*'
replacepattern: '$1 {{ source "latest7xSnapshot" }}'
43 changes: 43 additions & 0 deletions .github/workflows/updatecli.d/bump-latest-snapshot-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
name: Bump latest elastic-stack test version
pipelineid: 'bump-latest-elastic-stack-version'

actions:
default:
title: '[updatecli] Update latest snapshot to {{ source "latestSnapshot" }}'
kind: github/pullrequest
scmid: default
spec:
labels:
- automation
- dependency

scms:
default:
kind: github
spec:
owner: '{{ .scm.owner }}'
repository: '{{ .scm.repository }}'
user: '{{ requiredEnv "GITHUB_ACTOR" }}'
token: '{{ requiredEnv "GITHUB_TOKEN" }}'
commitusingapi: true
branch: main

sources:
latestSnapshot:
name: Get latest snapshot
kind: json
spec:
file: https://storage.googleapis.com/artifacts-api/snapshots/main.json
key: .version

targets:
update-snapshot:
name: '[updatecli] Update latest snapshot to {{ source "latestSnapshot" }}'
kind: file
sourceid: latestSnapshot
scmid: default
spec:
file: '.buildkite/pipeline.schedule-daily.yml'
matchpattern: '(STACK_VERSION:) 8\.[^\s]*\.[^\s]*'
replacepattern: '$1 {{ source "latestSnapshot" }}'
4 changes: 4 additions & 0 deletions .github/workflows/updatecli.d/scm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
scm:
owner: elastic
repository: integrations

0 comments on commit 6642c4f

Please sign in to comment.