From a2302d98c7dd30af3b4b4dc087c6cbbb263cb5e5 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Thu, 25 Jul 2024 09:29:56 +0200 Subject: [PATCH 1/5] Add github action to bump stack versions --- .../workflows/bump-elastic-stack-version.yml | 36 ++++++++++++++++ .../updatecli.d/bump-latest-7x-version.yml | 43 +++++++++++++++++++ .../bump-latest-snapshot-version.yml | 43 +++++++++++++++++++ .github/workflows/updatecli.d/scm.yml | 4 ++ 4 files changed, 126 insertions(+) create mode 100644 .github/workflows/bump-elastic-stack-version.yml create mode 100644 .github/workflows/updatecli.d/bump-latest-7x-version.yml create mode 100644 .github/workflows/updatecli.d/bump-latest-snapshot-version.yml create mode 100644 .github/workflows/updatecli.d/scm.yml diff --git a/.github/workflows/bump-elastic-stack-version.yml b/.github/workflows/bump-elastic-stack-version.yml new file mode 100644 index 00000000000..cfa3132bbc0 --- /dev/null +++ b/.github/workflows/bump-elastic-stack-version.yml @@ -0,0 +1,36 @@ +--- +name: Update versions of Elastic Stack dependencies + +on: + workflow_dispatch: + schedule: + - cron: '0 1 * * 1-5' + +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/updatecli-action@v2.62.0 # updatecli v0.80.0 + + - 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 }} diff --git a/.github/workflows/updatecli.d/bump-latest-7x-version.yml b/.github/workflows/updatecli.d/bump-latest-7x-version.yml new file mode 100644 index 00000000000..697b7d75b98 --- /dev/null +++ b/.github/workflows/updatecli.d/bump-latest-7x-version.yml @@ -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" }}' diff --git a/.github/workflows/updatecli.d/bump-latest-snapshot-version.yml b/.github/workflows/updatecli.d/bump-latest-snapshot-version.yml new file mode 100644 index 00000000000..65267d2403c --- /dev/null +++ b/.github/workflows/updatecli.d/bump-latest-snapshot-version.yml @@ -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" }}' diff --git a/.github/workflows/updatecli.d/scm.yml b/.github/workflows/updatecli.d/scm.yml new file mode 100644 index 00000000000..bc45e5d5dac --- /dev/null +++ b/.github/workflows/updatecli.d/scm.yml @@ -0,0 +1,4 @@ +--- +scm: + owner: elastic + repository: integrations From b3fd17e085c143e925dbadc0eb9b47fc553ddc40 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Thu, 25 Jul 2024 15:24:38 +0200 Subject: [PATCH 2/5] Trigger on comment --- .../workflows/bump-elastic-stack-version.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bump-elastic-stack-version.yml b/.github/workflows/bump-elastic-stack-version.yml index cfa3132bbc0..bc499d7dcde 100644 --- a/.github/workflows/bump-elastic-stack-version.yml +++ b/.github/workflows/bump-elastic-stack-version.yml @@ -5,12 +5,15 @@ on: workflow_dispatch: schedule: - cron: '0 1 * * 1-5' + issue_comment: + types: ['created'] permissions: contents: read jobs: bump-elastic-stack: + if: ${{ github.event_name != 'issue_comment' || (github.event.issue.pull_request && contains(github.event.comment.body, '/test bump-stack')) }} runs-on: ubuntu-latest permissions: contents: write @@ -23,14 +26,24 @@ jobs: - name: Install Updatecli in the runner uses: updatecli/updatecli-action@v2.62.0 # updatecli v0.80.0 + - name: Select diff action + if: ${{ github.event_name == 'issue_comment' }} + run: | + echo "UPDATECLI_ACTION=diff" >> $GITHUB_ENV + + - name: Select apply action + if: ${{ github.event_name != 'issue_comment' }} + run: | + echo "UPDATECLI_ACTION=apply" >> $GITHUB_ENV + - 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 + 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 apply --config .github/workflows/updatecli.d/bump-latest-snapshot-version.yml --values .github/workflows/updatecli.d/scm.yml + 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 }} From b1efc49c6436d925446df67be655ec055491df33 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Thu, 25 Jul 2024 15:34:56 +0200 Subject: [PATCH 3/5] Trigger on pull requests --- .github/workflows/bump-elastic-stack-version.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/bump-elastic-stack-version.yml b/.github/workflows/bump-elastic-stack-version.yml index bc499d7dcde..55f091801e5 100644 --- a/.github/workflows/bump-elastic-stack-version.yml +++ b/.github/workflows/bump-elastic-stack-version.yml @@ -5,15 +5,16 @@ on: workflow_dispatch: schedule: - cron: '0 1 * * 1-5' - issue_comment: - types: ['created'] + pull_request: + paths: + - .github/updatecli.d/* + - .github/workflows/bump-elastic-stack-version.yml permissions: contents: read jobs: bump-elastic-stack: - if: ${{ github.event_name != 'issue_comment' || (github.event.issue.pull_request && contains(github.event.comment.body, '/test bump-stack')) }} runs-on: ubuntu-latest permissions: contents: write @@ -27,12 +28,12 @@ jobs: uses: updatecli/updatecli-action@v2.62.0 # updatecli v0.80.0 - name: Select diff action - if: ${{ github.event_name == 'issue_comment' }} + if: ${{ github.event_name == 'pull_request' }} run: | echo "UPDATECLI_ACTION=diff" >> $GITHUB_ENV - name: Select apply action - if: ${{ github.event_name != 'issue_comment' }} + if: ${{ github.event_name != 'pull_request' }} run: | echo "UPDATECLI_ACTION=apply" >> $GITHUB_ENV From ee75a03e4fe5abcd898874fec6ac39d90b0c7ac7 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Thu, 25 Jul 2024 17:29:13 +0200 Subject: [PATCH 4/5] Add config to dependabot --- .github/dependabot.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 2fc0a42c168..280fee79f97 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,3 +9,9 @@ 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 From a4f8c5f12c49ef7b9695e096b8aa3a205e6e90de Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Thu, 25 Jul 2024 18:15:38 +0200 Subject: [PATCH 5/5] Add labels and reviewers --- .github/dependabot.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 280fee79f97..ea5e8584b33 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -15,3 +15,7 @@ updates: # Check for updates to GitHub Actions every week interval: "weekly" open-pull-requests-limit: 2 + labels: + - automation + reviewers: + - "elastic/ecosystem"