Skip to content

Commit

Permalink
ci: use updatecli with GitHub secrets (#1158)
Browse files Browse the repository at this point in the history
  • Loading branch information
v1v authored May 29, 2024
1 parent 0273f82 commit a3c00d4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 30 deletions.
13 changes: 7 additions & 6 deletions .ci/updatecli/updatecli.d/update-gherkin-specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,21 @@ scms:
default:
kind: github
spec:
user: '{{ requiredEnv "GIT_USER" }}'
email: '{{ requiredEnv "GIT_EMAIL" }}'
user: '{{ requiredEnv "GITHUB_ACTOR" }}'
owner: "{{ .github.owner }}"
repository: "{{ .github.repository }}"
token: '{{ requiredEnv "GITHUB_TOKEN" }}'
username: '{{ requiredEnv "GIT_USER" }}'
username: '{{ requiredEnv "GITHUB_ACTOR" }}'
branch: "{{ .github.branch }}"
commitusingapi: true
apm:
kind: github
spec:
user: '{{ requiredEnv "GIT_USER" }}'
email: '{{ requiredEnv "GIT_EMAIL" }}'
user: '{{ requiredEnv "GITHUB_ACTOR" }}'
owner: "{{ .github.owner }}"
repository: "{{ .github.apm_repository }}"
token: '{{ requiredEnv "GITHUB_TOKEN" }}'
username: '{{ requiredEnv "GIT_USER" }}'
username: '{{ requiredEnv "GITHUB_ACTOR" }}'
branch: "{{ .github.branch }}"

sources:
Expand Down Expand Up @@ -78,5 +77,7 @@ targets:
disablesourceinput: true
kind: shell
spec:
# git diff helps to print what it changed, If it is empty, then updatecli report a success with no changes applied.
# See https://www.updatecli.io/docs/plugins/resource/shell/#_shell_target
command: 'tar -xzf {{ requiredEnv "GITHUB_WORKSPACE" }}/gherkin-specs.tgz && git --no-pager diff'
workdir: "{{ .apm_agent.gherkin_specs_path }}"
13 changes: 7 additions & 6 deletions .ci/updatecli/updatecli.d/update-json-specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,21 @@ scms:
default:
kind: github
spec:
user: '{{ requiredEnv "GIT_USER" }}'
email: '{{ requiredEnv "GIT_EMAIL" }}'
user: '{{ requiredEnv "GITHUB_ACTOR" }}'
owner: "{{ .github.owner }}"
repository: "{{ .github.repository }}"
token: '{{ requiredEnv "GITHUB_TOKEN" }}'
username: '{{ requiredEnv "GIT_USER" }}'
username: '{{ requiredEnv "GITHUB_ACTOR" }}'
branch: "{{ .github.branch }}"
commitusingapi: true
apm:
kind: github
spec:
user: '{{ requiredEnv "GIT_USER" }}'
email: '{{ requiredEnv "GIT_EMAIL" }}'
user: '{{ requiredEnv "GITHUB_ACTOR" }}'
owner: "{{ .github.owner }}"
repository: "{{ .github.apm_repository }}"
token: '{{ requiredEnv "GITHUB_TOKEN" }}'
username: '{{ requiredEnv "GIT_USER" }}'
username: '{{ requiredEnv "GITHUB_ACTOR" }}'
branch: "{{ .github.branch }}"

sources:
Expand Down Expand Up @@ -78,5 +77,7 @@ targets:
disablesourceinput: true
kind: shell
spec:
# git diff helps to print what it changed, If it is empty, then updatecli report a success with no changes applied.
# See https://www.updatecli.io/docs/plugins/resource/shell/#_shell_target
command: 'tar -xzf {{ requiredEnv "GITHUB_WORKSPACE" }}/json-specs.tgz && git --no-pager diff'
workdir: "{{ .apm_agent.json_specs_path }}"
15 changes: 8 additions & 7 deletions .ci/updatecli/updatecli.d/update-specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,22 @@ scms:
default:
kind: github
spec:
user: '{{ requiredEnv "GIT_USER" }}'
email: '{{ requiredEnv "GIT_EMAIL" }}'
user: '{{ requiredEnv "GITHUB_ACTOR" }}'
owner: "{{ .github.owner }}"
repository: "{{ .github.repository }}"
token: '{{ requiredEnv "GITHUB_TOKEN" }}'
username: '{{ requiredEnv "GIT_USER" }}'
username: '{{ requiredEnv "GITHUB_ACTOR" }}'
branch: "{{ .github.branch }}"
commitusingapi: true

apm-data:
kind: github
spec:
user: '{{ requiredEnv "GIT_USER" }}'
email: '{{ requiredEnv "GIT_EMAIL" }}'
user: '{{ requiredEnv "GITHUB_ACTOR" }}'
owner: "{{ .github.owner }}"
repository: "{{ .github.apm_data_repository }}"
token: '{{ requiredEnv "GITHUB_TOKEN" }}'
username: '{{ requiredEnv "GIT_USER" }}'
username: '{{ requiredEnv "GITHUB_ACTOR" }}'
branch: "{{ .github.branch }}"

sources:
Expand Down Expand Up @@ -71,7 +70,7 @@ actions:
*Changeset*
* {{ source "pull_request" }}
* https://github.com/{{ .github.owner }}/{{ .github.apm_data_repository }}/commit/{{ source "sha" }}
title: '[Automation] Update JSON schema specs'
title: '[Automation] Update JSON server schema specs'

targets:
agent-json-schema:
Expand All @@ -80,5 +79,7 @@ targets:
disablesourceinput: true
kind: shell
spec:
# git diff helps to print what it changed, If it is empty, then updatecli report a success with no changes applied.
# See https://www.updatecli.io/docs/plugins/resource/shell/#_shell_target
command: 'tar -xzf {{ requiredEnv "GITHUB_WORKSPACE" }}/json-schema.tgz && git --no-pager diff'
workdir: "{{ .apm_agent.server_schema_specs_path }}"
21 changes: 10 additions & 11 deletions .github/workflows/updatecli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: elastic/apm-pipeline-library/.github/actions/updatecli@current

- uses: elastic/oblt-actions/updatecli/run@v1
with:
vaultUrl: ${{ secrets.VAULT_ADDR }}
vaultRoleId: ${{ secrets.VAULT_ROLE_ID }}
vaultSecretId: ${{ secrets.VAULT_SECRET_ID }}
pipeline: .ci/updatecli/updatecli.d
values: .ci/updatecli/values.yml
command: "--experimental apply --config .ci/updatecli/updatecli.d --values .ci/updatecli/values.yml"
env:
GITHUB_TOKEN: ${{ secrets.UPDATECLI_GH_TOKEN }}

- if: failure()
uses: elastic/apm-pipeline-library/.github/actions/notify-build-status@current
uses: elastic/oblt-actions/slack/send@v1
with:
vaultUrl: ${{ secrets.VAULT_ADDR }}
vaultRoleId: ${{ secrets.VAULT_ROLE_ID }}
vaultSecretId: ${{ secrets.VAULT_SECRET_ID }}
slackChannel: "#apm-agent-php"
bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
channel-id: "#apm-agent-php"
message: ":traffic_cone: updatecli failed for `${{ github.repository }}@${{ github.ref_name }}`, @robots-ci please look what's going on <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|here>"

0 comments on commit a3c00d4

Please sign in to comment.