Browse Source

sets eso-service-account for creating e2e comments (#3678)

Signed-off-by: Gustavo Carvalho <gusfcarvalho@gmail.com>
Gustavo Fernandes de Carvalho 1 year ago
parent
commit
c9162b6179
1 changed files with 14 additions and 20 deletions
  1. 14 20
      .github/workflows/e2e.yml

+ 14 - 20
.github/workflows/e2e.yml

@@ -8,6 +8,8 @@ permissions:
   contents: read
   issues: write
   pull-requests: write
+  checks: write
+  statuses: read
 name: e2e tests
 
 env:
@@ -92,7 +94,11 @@ jobs:
 
     - id: e2e
       uses: ./.github/actions/e2e
-
+    - id: create_token
+      uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
+      with:
+        app_id: ${{ secrets.APP_ID }}
+        private_key: ${{ secrets.PRIVATE_KEY }}
     # Update check run called "integration-fork"
     - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
       id: update-check-run
@@ -103,7 +109,7 @@ jobs:
         # Conveniently, job.status maps to https://developer.github.com/v3/checks/runs/#update-a-check-run
         conclusion: ${{ job.status }}
       with:
-        github-token: ${{ secrets.TEST_GITHUB_TOKEN }}
+        github-token: ${{ steps.create_token.outputs.token }}
         script: |
           const { data: pull } = await github.rest.pulls.get({
             ...context.repo,
@@ -126,31 +132,19 @@ jobs:
             conclusion: process.env.conclusion
           });
           return result;
-    - name: Find Comment
-      if: always()
-      uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0
-      id: fc
-      with:
-        token: ${{ secrets.TEST_GITHUB_TOKEN }}
-        issue-number: ${{ github.event.client_payload.pull_request.number }}
-        body-includes: /ok-to-test sha=${{ env.TARGET_SHA }}
     - name: Update on Succeess
-      if: always() && steps.fc.outputs.comment-id != '' &&  steps.e2e.conclusion == 'success'
+      if: always() && steps.e2e.conclusion == 'success'
       uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
       with:
-        token: ${{ secrets.TEST_GITHUB_TOKEN }}
+        token: ${{ steps.create_token.outputs.token }}
         issue-number: ${{ github.event.client_payload.pull_request.number }}
         body: |
-            [Bot] - :white_check_mark: [e2e tests pass](https://github.com/external-secrets/external-secrets/actions/runs/${{ steps.update-check-run.outputs.result.id }})
-        reactions: +1
-        edit-mode: append
+            [Bot] - :white_check_mark: [e2e for $TARGET_SHA passed](https://github.com/external-secrets/external-secrets/actions/runs/${{ github.run_id }})
     - name: Update on Failure
-      if: always() && steps.fc.outputs.comment-id != '' &&  steps.e2e.conclusion != 'success'
+      if: always() &&  steps.e2e.conclusion != 'success'
       uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
       with:
-        token: ${{ secrets.TEST_GITHUB_TOKEN }}
+        token: ${{ steps.create_token.outputs.token }}
         issue-number: ${{ github.event.client_payload.pull_request.number }}
         body: |
-            [Bot] - :x: [e2e tests failed](https://github.com/external-secrets/external-secrets/actions/runs/${{ steps.update-check-run.outputs.result.id }})
-        reactions: -1
-        edit-mode: append
+            [Bot] - :x: [e2e for $TARGET_SHA failed](https://github.com/external-secrets/external-secrets/actions/runs/${{ github.run_id }})