From 3b8a4ba75df3de1676d7271263992bcc26bfdb38 Mon Sep 17 00:00:00 2001 From: Bastian Krol Date: Thu, 15 Feb 2024 11:27:34 +0100 Subject: [PATCH] [dash0] fix action to update the .env file --- .github/actions/update-env-file/action.yaml | 37 +++++++++++++++++---- .github/workflows/release.yml | 1 + regenerate-grpc-code.sh | 1 - 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/.github/actions/update-env-file/action.yaml b/.github/actions/update-env-file/action.yaml index 30f01f9346..4d66532d4d 100644 --- a/.github/actions/update-env-file/action.yaml +++ b/.github/actions/update-env-file/action.yaml @@ -4,7 +4,10 @@ name: Deploy Dash0 OTel Demo description: deploy a release of the Dash0 fork of the OpenTelemetry demo inputs: containerImageVersion: - description: 'version tag of the Dash0 OTel Demo container images, e.g. 1.1.0' + description: "version tag of the Dash0 OTel Demo container images, e.g. 1.1.0" + required: true + token: + description: "token granting read/write access to dash0-configuration repository." required: true runs: @@ -19,9 +22,29 @@ runs: shell: bash run: | sed -i "s/^IMAGE_VERSION=[[:digit:]][[:digit:]]*\.[[:digit:]][[:digit:]]*\.[[:digit:]][[:digit:]]*$/IMAGE_VERSION=${{ inputs.containerImageVersion }}/" .env - git --no-pager diff .env - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - git add .env - git commit -m"[dash0] update image version in .env to ${{ inputs.containerImageVersion }}" - git push + + - name: create pull request + id: cpr + uses: peter-evans/create-pull-request@v5 + with: + title: update .env file with latest tag + commit-message: '[dash0] update image version in .env to ${{ inputs.containerImageVersion }}' + add-paths: .env + base: main + branch: env-file-update + author: 'github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>' + + - name: auto approve + if: steps.cpr.outputs.pull-request-operation == 'created' + run: gh pr review --approve "${{ steps.cpr.outputs.pull-request-number }}" + shell: bash + env: + GH_TOKEN: ${{ inputs.token }} + + - name: enable pull request auto merge + if: steps.cpr.outputs.pull-request-operation == 'created' + uses: peter-evans/enable-pull-request-automerge@v3 + with: + token: ${{ inputs.token }} + pull-request-number: ${{ steps.cpr.outputs.pull-request-number }} + merge-method: squash diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8329aa94c1..3fee24d3f9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -49,3 +49,4 @@ jobs: uses: ./.github/actions/update-env-file with: containerImageVersion: ${{ github.event.release.tag_name }} + token: ${{ secrets.REPOSITORY_FULL_ACCESS_GITHUB_TOKEN }} diff --git a/regenerate-grpc-code.sh b/regenerate-grpc-code.sh index 5d6ff44c58..7e679c0808 100755 --- a/regenerate-grpc-code.sh +++ b/regenerate-grpc-code.sh @@ -8,7 +8,6 @@ set -euo pipefail # This script is used to update generated code after changing demo.proto. cd -P -- "$(dirname -- "$0")" -pwd command -v npm >/dev/null 2>&1 || { cat <&2