From ba850562571b336e39aa09ab412e33f544f58043 Mon Sep 17 00:00:00 2001 From: Hector Castejon Diaz Date: Tue, 22 Oct 2024 14:57:09 +0200 Subject: [PATCH] [Internal] Automatically trigger integration tests --- .github/workflows/integration-tests.yml | 47 +++++++++---------------- 1 file changed, 17 insertions(+), 30 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index fb33970ff..89d8be962 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -9,45 +9,32 @@ on: jobs: - write-message: + trigger-tests: if: github.event_name == 'pull_request' - name: Write Message + name: Trigger Tests runs-on: ubuntu-latest + environment: "test-trigger-is" steps: - uses: actions/checkout@v3 - - name: Delete old comments - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - # Delete previous comment if it exists - previous_comment_ids=$(gh api "repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" \ - --jq '.[] | select(.body | startswith("")) | .id') - echo "Previous comment IDs: $previous_comment_ids" - # Iterate over each comment ID and delete the comment - if [ ! -z "$previous_comment_ids" ]; then - echo "$previous_comment_ids" | while read -r comment_id; do - echo "Deleting comment with ID: $comment_id" - gh api "repos/${{ github.repository }}/issues/comments/$comment_id" -X DELETE - done - fi - - - name: Write new comment + - name: Generate GitHub App Token + id: generate-token + uses: actions/create-github-app-token@v1 + with: + app-id: ${{ secrets.DECO_WORKFLOW_TRIGGER_APP_ID }} + private-key: ${{ secrets.DECO_WORKFLOW_TRIGGER_PRIVATE_KEY }} + owner: ${{ secrets.ORG_NAME }} + repositories: ${{secrets.REPO_NAME}} + + - name: Trigger Workflow in Another Repo env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ steps.generate-token.outputs.token }} run: | - gh pr comment ${{ github.event.pull_request.number }} --body \ - " - Run integration tests using the corresponding workflow: - - Inputs: - PR Number:${{github.event.pull_request.number}} - Commit SHA:${{ github.event.pull_request.head.sha }} - - This check will be approved automatically on success. - " + gh workflow run sdk-go-isolated-pr.yml -R ${{ secrets.ORG_NAME }}/${{secrets.REPO_NAME}}} + -f pull_request_number=${{ github.event.pull_request.number }} -f commit_sha=${{ github.event.pull_request.head.sha }} -f branch=${{ github.head.ref }} -f repo=${{ github.repository }} -f org=${{ secrets.ORG_NAME }} -f repo_name=${{secrets.REPO_NAME}} -f workflow_name=${{secrets.WORKFLOW_NAME}} -f app_id=${{ secrets.DECO_WORKFLOW_TRIGGER_APP_ID }} -f private_key=${{ secrets.DECO_WORKFLOW_TRIGGER_PRIVATE_KEY }} -f gh_token=${{ steps.generate-token.outputs.token }} + # The hash for the merge queue may not be the same as the hash for the PR. # Auto approve the check for the merge queue to avoid running integration tests twice. auto-approve: