diff --git a/.github/workflows/run-updatecli.yml b/.github/workflows/run-updatecli.yml new file mode 100644 index 000000000..1a309c189 --- /dev/null +++ b/.github/workflows/run-updatecli.yml @@ -0,0 +1,46 @@ +--- +name: Run updatecli + +on: + workflow_dispatch: + schedule: + - cron: '0 1 * * 1-5' + pull_request: + paths: + - .github/workflows/updatecli/** + - .github/workflows/run-updatecli.yml + +permissions: + contents: read + +jobs: + updatecli: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + strategy: + fail-fast: false + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + + - 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: Install Updatecli in the runner + uses: updatecli/updatecli-action@2c3221bc5f4499a99fec2c87d9de4a83cb30e990 #v3.1.3 + + - name: Run updatecli + # --experimental needed for commitusingapi option. + run: updatecli --experimental ${{ env.UPDATECLI_ACTION }} --config .github/workflows/updatecli --values .github/workflows/updatecli/values.d/scm.yml + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/updatecli/updatecli.d/bump-package-registry-categories-version.yml b/.github/workflows/updatecli/updatecli.d/bump-package-registry-categories-version.yml new file mode 100644 index 000000000..c3d9778ff --- /dev/null +++ b/.github/workflows/updatecli/updatecli.d/bump-package-registry-categories-version.yml @@ -0,0 +1,43 @@ +--- +name: Bump Package Registry categories version +pipelineid: 'bump-package-registry-categories-version' + +actions: + default: + title: '[updatecli] Update Package Registry categories URL to {{ source "latestRegistryVersion" }}' + kind: github/pullrequest + scmid: default + spec: + labels: + - automation + +scms: + default: + kind: github + spec: + owner: '{{ .scm.owner }}' + repository: '{{ .scm.repository }}' + user: '{{ requiredEnv "GITHUB_ACTOR" }}' + username: '{{ 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-categories-url: + name: '[updatecli] Update Package Registry categories URL to {{ source "latestRegistryVersion" }}' + kind: file + sourceid: latestRegistryVersion + scmid: default + spec: + file: code/go/internal/validator/semantic/validate_datastream_package_categories.go + matchpattern: 'package-registry/v[0-9\.]+/categories/categories\.yml' + replacepattern: 'package-registry/{{ source "latestRegistryVersion" }}/categories/categories.yml' diff --git a/.github/workflows/updatecli/values.d/scm.yml b/.github/workflows/updatecli/values.d/scm.yml new file mode 100644 index 000000000..ccc5c4289 --- /dev/null +++ b/.github/workflows/updatecli/values.d/scm.yml @@ -0,0 +1,4 @@ +--- +scm: + owner: elastic + repository: package-spec