Skip to content

Commit 208254a

Browse files
committed
[Internal] Automatically trigger integration tests on PR
1 parent d3b85cb commit 208254a

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

.github/integration-tests.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Integration Tests
2+
3+
on:
4+
5+
pull_request:
6+
types: [opened, synchronize]
7+
8+
merge_group:
9+
10+
11+
jobs:
12+
trigger-tests:
13+
if: github.event_name == 'pull_request'
14+
name: Trigger Tests
15+
runs-on: ubuntu-latest
16+
environment: "test-trigger-is"
17+
18+
steps:
19+
- uses: actions/checkout@v3
20+
21+
- name: Generate GitHub App Token
22+
id: generate-token
23+
uses: actions/create-github-app-token@v1
24+
with:
25+
app-id: ${{ secrets.DECO_WORKFLOW_TRIGGER_APP_ID }}
26+
private-key: ${{ secrets.DECO_WORKFLOW_TRIGGER_PRIVATE_KEY }}
27+
owner: ${{ secrets.ORG_NAME }}
28+
repositories: ${{secrets.REPO_NAME}}
29+
30+
- name: Trigger Workflow in Another Repo
31+
env:
32+
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
33+
run: |
34+
gh workflow run sdk-py-isolated-pr.yml -R ${{ secrets.ORG_NAME }}/${{secrets.REPO_NAME}} \
35+
--ref main \
36+
-f pull_request_number=${{ github.event.pull_request.number }} \
37+
-f commit_sha=${{ github.event.pull_request.head.sha }}
38+
39+
40+
# The hash for the merge queue may not be the same as the hash for the PR.
41+
# Auto approve the check for the merge queue to avoid running integration tests twice.
42+
auto-approve:
43+
if: github.event_name == 'merge_group'
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: Mark Check
47+
env:
48+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
shell: bash
50+
run: |
51+
gh api -X POST -H "Accept: application/vnd.github+json" \
52+
-H "X-GitHub-Api-Version: 2022-11-28" \
53+
/repos/${{ github.repository }}/statuses/${{ github.sha }} \
54+
-f 'state=success' \
55+
-f 'context=Integration Tests Check'

0 commit comments

Comments
 (0)