Skip to content

Commit

Permalink
Fixes bump elastic stack workflow (#1862)
Browse files Browse the repository at this point in the history
Fix some issues found after running the workflow:
- Enable execution by changing from diff to apply.
- Each target is executed in a different updatecli run, so they create different PRs with more meaningful titles.
- --experimental flag is required to use commitusingapi option.
- Updated updatecli-action to latest version.
  • Loading branch information
jsoriano authored May 23, 2024
1 parent b1dcda0 commit 2a03edd
Show file tree
Hide file tree
Showing 5 changed files with 159 additions and 56 deletions.
32 changes: 25 additions & 7 deletions .github/workflows/bump-elastic-stack-version.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
name: bump-elastic-stack-version
name: Update versions of Elastic Stack dependencies

on:
workflow_dispatch:
schedule:
- cron: '0 15 * * 1-5'
- cron: '0 1 * * 1-5'

permissions:
contents: read
Expand All @@ -21,10 +21,28 @@ jobs:
- uses: actions/checkout@v4

- name: Install Updatecli in the runner
uses: updatecli/updatecli-action@9a37c7e35598d7b37d8e7568b40ed9538112be01 # v0.76.1
uses: updatecli/updatecli-action@v2.58.0 # updatecli v0.77.0

- name: Run Updatecli in Apply mode
# TODO: Change from diff to apply.
run: updatecli diff --config .github/workflows/updatecli.d/bump-elastic-stack-version.yml --values .github/workflows/updatecli.d/scm.yml
- name: Update default stack version
# --experimental needed for commitusingapi option.
run: updatecli --experimental apply --config .github/workflows/updatecli.d/bump-elastic-stack-version.yml --values .github/workflows/updatecli.d/scm.yml
env:
GITHUB_TOKEN: ${{ secrets.ECOSYSTEM_USER_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Update latest testing 7.x stack version
# --experimental needed for commitusingapi option.
run: updatecli --experimental apply --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 apply --config .github/workflows/updatecli.d/bump-latest-snapshot-version.yml --values .github/workflows/updatecli.d/scm.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Update Package Registry version
# --experimental needed for commitusingapi option.
run: updatecli --experimental apply --config .github/workflows/updatecli.d/bump-package-registry-version.yml --values .github/workflows/updatecli.d/scm.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54 changes: 5 additions & 49 deletions .github/workflows/updatecli.d/bump-elastic-stack-version.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
name: Bump elastic-stack versions
pipelineid: 'bump-elastic-stack-version'
name: Bump elastic-stack default version
pipelineid: 'bump-elastic-stack-default-version'

actions:
default:
title: '[updatecli] update elastic stack version for testing {{ source "latestVersion" }}'
title: '[updatecli] Update default stack version to {{ source "latest8xVersion" }}'
kind: github/pullrequest
scmid: default
spec:
Expand All @@ -21,20 +21,9 @@ scms:
user: '{{ requiredEnv "GITHUB_ACTOR" }}'
token: '{{ requiredEnv "GITHUB_TOKEN" }}'
commitusingapi: true
branch: main

sources:
latestSnapshot:
name: Get latest snapshot build
kind: json
spec:
file: https://storage.googleapis.com/artifacts-api/snapshots/main.json
key: .build_id
latest7xSnapshot:
name: Get latest 7.x snapshot build
kind: json
spec:
file: https://storage.googleapis.com/artifacts-api/snapshots/7.17.json
key: .build_id
latest8xVersion:
name: Get latest 8.x version
kind: file
Expand All @@ -45,47 +34,14 @@ sources:
captureindex: 1
spec:
file: https://storage.googleapis.com/artifacts-api/releases/current/8
latestRegistryVersion:
name: Get latest Package Registry version
kind: json
spec:
file: https://api.github.com/repos/elastic/package-registry/releases/latest
key: .tag_name

targets:
update-snapshot:
name: "Update snapshot"
kind: file
sourceid: latestSnapshot
scmid: default
spec:
file: Makefile
matchpattern: '(./scripts/test-stack-command.sh) 8\.[^\s]+-SNAPSHOT'
replacepattern: '$1 {{ source "latestSnapshot" }}-SNAPSHOT'
update-7x-version:
name: "Update 7.x version"
kind: file
sourceid: latest7xSnapshot
scmid: default
spec:
file: Makefile
matchpattern: '(./scripts/test-stack-command.sh) 7\.17\.[^\s]*'
replacepattern: '$1 {{ source "latest7xSnapshot" }}-SNAPSHOT'
update-default-version:
name: "Update default version"
name: '[updatecli] Update default stack version to {{ source "latest8xVersion" }}'
kind: file
sourceid: latest8xVersion
scmid: default
spec:
file: internal/install/stack_version.go
matchpattern: '(DefaultStackVersion =) "[^"]+"'
replacepattern: '$1 "{{ source "latest8xVersion" }}"'
update-package-registry-base-image:
name: "Update Package Registry base image"
kind: file
sourceid: latestRegistryVersion
scmid: default
spec:
file: internal/stack/resources.go
matchpattern: '"(docker.elastic.co/package-registry/package-registry):v[0-9\.]+"'
replacepattern: '"$1:{{ source "latestRegistryVersion" }}"'
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 build
kind: json
spec:
file: https://storage.googleapis.com/artifacts-api/snapshots/7.17.json
key: .build_id

targets:
update-7x-version:
name: '[updatecli] Update 7.x snapshot to {{ source "latest7xSnapshot" }}'
kind: file
sourceid: latest7xSnapshot
scmid: default
spec:
file: Makefile
matchpattern: '(./scripts/test-stack-command.sh) 7\.17\.[^\s]*'
replacepattern: '$1 {{ source "latest7xSnapshot" }}-SNAPSHOT'
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 build
kind: json
spec:
file: https://storage.googleapis.com/artifacts-api/snapshots/main.json
key: .build_id

targets:
update-snapshot:
name: '[updatecli] Update latest snapshot to {{ source "latestSnapshot" }}'
kind: file
sourceid: latestSnapshot
scmid: default
spec:
file: Makefile
matchpattern: '(./scripts/test-stack-command.sh) 8\.[^\s]+-SNAPSHOT'
replacepattern: '$1 {{ source "latestSnapshot" }}-SNAPSHOT'
43 changes: 43 additions & 0 deletions .github/workflows/updatecli.d/bump-package-registry-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
name: Bump Package Registry version
pipelineid: 'bump-package-registry-version'

actions:
default:
title: '[updatecli] Update Package Registry base image to {{ source "latestRegistryVersion" }}'
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:
latestRegistryVersion:
name: Get latest Package Registry version
kind: json
spec:
file: https://api.github.com/repos/elastic/package-registry/releases/latest
key: .tag_name

targets:
update-package-registry-base-image:
name: '[updatecli] Update Package Registry base image to {{ source "latestRegistryVersion" }}'
kind: file
sourceid: latestRegistryVersion
scmid: default
spec:
file: internal/stack/resources.go
matchpattern: '"(docker.elastic.co/package-registry/package-registry):v[0-9\.]+"'
replacepattern: '"$1:{{ source "latestRegistryVersion" }}"'

0 comments on commit 2a03edd

Please sign in to comment.