From 7dcb20238aad38a7aec1c70c38788a9224e6543f Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 7 Feb 2023 14:54:39 +0100 Subject: [PATCH] action: update specs --- .ci/update-specs.yml | 57 +++++++++++++++++++++++++++++ .github/workflows/opentelemetry.yml | 1 + .github/workflows/update-specs.yml | 30 +++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 .ci/update-specs.yml create mode 100644 .github/workflows/update-specs.yml diff --git a/.ci/update-specs.yml b/.ci/update-specs.yml new file mode 100644 index 00000000..5a9941df --- /dev/null +++ b/.ci/update-specs.yml @@ -0,0 +1,57 @@ +--- +name: update specs + +scms: + githubConfig: + kind: github + spec: + user: '{{ requiredEnv "GIT_USER" }}' + email: '{{ requiredEnv "GIT_EMAIL" }}' + owner: elastic + repository: ecs-logging-java + token: '{{ requiredEnv "GITHUB_TOKEN" }}' + username: '{{ requiredEnv "GIT_USER" }}' + branch: main + +actions: + ecs-logging-java: + kind: github/pullrequest + scmid: githubConfig + sourceid: sha + spec: + automerge: false + labels: + - dependencies + title: 'synchronize ecs-logging spec' + description: |- + ### What + + ECS logging specs automatic sync + + ### Why + + *Changeset* + * https://github.com/elastic/ecs-logging/commit/{{ source "sha" }} + +sources: + spec.json: + name: Get specs from json + kind: file + spec: + file: https://raw.githubusercontent.com/elastic/ecs-logging/main/spec/spec.json + + sha: + name: Get commit + kind: json + spec: + file: 'https://api.github.com/repos/elastic/ecs-logging/commits?path=spec%2Fspec.json&page=1&per_page=1' + key: ".[0].sha" + +targets: + spec.json-update: + name: 'synchronize ecs-logging spec' + kind: file + sourceid: spec.json + scmid: githubConfig + spec: + file: ecs-logging-core/src/test/resources/spec/spec.json diff --git a/.github/workflows/opentelemetry.yml b/.github/workflows/opentelemetry.yml index 143d4fab..f1e39a61 100644 --- a/.github/workflows/opentelemetry.yml +++ b/.github/workflows/opentelemetry.yml @@ -6,6 +6,7 @@ on: workflows: - test - test-reporter + - update-specs types: [completed] jobs: diff --git a/.github/workflows/update-specs.yml b/.github/workflows/update-specs.yml new file mode 100644 index 00000000..13ded159 --- /dev/null +++ b/.github/workflows/update-specs.yml @@ -0,0 +1,30 @@ +--- +# Send PRs to the subscribed ECS Agents if the spec files (JSON) are modified +name: update-specs + +on: + workflow_dispatch: + schedule: + - cron: '0 6 * * *' + +permissions: + pull-requests: write + contents: write + +jobs: + bump: + runs-on: ubuntu-latest + steps: + + - uses: actions/checkout@v3 + + - name: Setup Git + uses: elastic/apm-pipeline-library/.github/actions/setup-git@current + + - name: Install Updatecli in the runner + uses: updatecli/updatecli-action@453502948b442d7b9a923de7b40cc7ce8628505c + + - name: Run Updatecli + env: + GITHUB_TOKEN: ${{ github.token }} + run: updatecli apply --config ./.ci/update-specs.yml