|
1 | 1 | name: E2E Tests on Kind |
2 | 2 |
|
3 | 3 | on: |
4 | | - schedule: |
5 | | - - cron: "0 5 * * *" |
6 | | - workflow_dispatch: |
7 | | - inputs: |
8 | | - debug_enabled: |
9 | | - type: boolean |
10 | | - description: "Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)" |
11 | | - required: false |
12 | | - default: false |
13 | 4 | pull_request: |
14 | 5 | types: [opened, synchronize, reopened] |
15 | 6 | paths: |
|
22 | 13 | cancel-in-progress: true |
23 | 14 | name: e2e tests |
24 | 15 | runs-on: ubuntu-latest |
| 16 | + if: > |
| 17 | + (github.event_name == 'pull_request_target' || github.event_name == 'pull_request_target') && |
| 18 | + contains(fromJson('["chmouel", "zakisk"]'), github.event.pull_request.user.login) |
25 | 19 | strategy: |
26 | 20 | matrix: |
27 | 21 | provider: [providers, gitea_others] |
|
57 | 51 | with: |
58 | 52 | ref: ${{ github.event.pull_request.head.sha }} |
59 | 53 |
|
| 54 | + - name: Check if user is an admin |
| 55 | + id: check-permissions |
| 56 | + run: | |
| 57 | + set -x |
| 58 | + USER_LOGIN="${{ github.event.pull_request.user.login }}" |
| 59 | + REPO_FULL_NAME="${{ github.repository }}" |
| 60 | + echo "Checking permissions for user: $USER_LOGIN in repo: $REPO_FULL_NAME" |
| 61 | +
|
| 62 | + # Fetch user permissions using GitHub API |
| 63 | + PERMISSIONS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ |
| 64 | + "https://api.github.com/repos/$REPO_FULL_NAME/collaborators/$USER_LOGIN/permission") |
| 65 | +
|
| 66 | + # Extract the permission level |
| 67 | + PERMISSION_LEVEL=$(echo "$PERMISSIONS" | jq -r '.permission') |
| 68 | +
|
| 69 | + # Set output variable to indicate if the user is an admin |
| 70 | + if [[ "$PERMISSION_LEVEL" == "admin" ]]; then |
| 71 | + echo "User is an admin." |
| 72 | + echo "is-admin=true" >> $GITHUB_OUTPUT |
| 73 | + else |
| 74 | + echo "User is not an admin." |
| 75 | + echo "is-admin=false" >> $GITHUB_OUTPUT |
| 76 | + fi |
| 77 | + shell: bash |
| 78 | + |
60 | 79 | - uses: actions/setup-go@v5 |
61 | 80 | with: |
62 | 81 | go-version-file: "go.mod" |
@@ -102,26 +121,7 @@ jobs: |
102 | 121 | ./hack/gh-workflow-ci.sh create_second_github_app_controller_on_ghe |
103 | 122 |
|
104 | 123 | - name: Run E2E Tests on pull_request |
105 | | - if: ${{ github.event_name != 'schedule' }} |
106 | | - env: |
107 | | - TEST_PROVIDER: ${{ matrix.provider }} |
108 | | - TEST_BITBUCKET_CLOUD_TOKEN: ${{ secrets.BITBUCKET_CLOUD_TOKEN }} |
109 | | - TEST_EL_WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }} |
110 | | - TEST_GITEA_SMEEURL: ${{ secrets.TEST_GITEA_SMEEURL }} |
111 | | - TEST_GITHUB_REPO_INSTALLATION_ID: ${{ secrets.INSTALLATION_ID }} |
112 | | - TEST_GITHUB_TOKEN: ${{ secrets.GH_APPS_TOKEN }} |
113 | | - TEST_GITHUB_SECOND_TOKEN: ${{ secrets.TEST_GITHUB_SECOND_TOKEN }} |
114 | | - TEST_GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }} |
115 | | - TEST_BITBUCKET_SERVER_TOKEN: ${{ secrets.BITBUCKET_SERVER_TOKEN }} |
116 | | - TEST_BITBUCKET_SERVER_API_URL: ${{ secrets.BITBUCKET_SERVER_API_URL }} |
117 | | - TEST_BITBUCKET_SERVER_WEBHOOK_SECRET: ${{ secrets.BITBUCKET_SERVER_WEBHOOK_SECRET }} |
118 | | - run: | |
119 | | - ./hack/gh-workflow-ci.sh run_e2e_tests |
120 | | -
|
121 | | - - name: Run E2E Tests on nightly |
122 | | - if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} |
123 | 124 | env: |
124 | | - NIGHTLY_E2E_TEST: "true" |
125 | 125 | TEST_PROVIDER: ${{ matrix.provider }} |
126 | 126 | TEST_BITBUCKET_CLOUD_TOKEN: ${{ secrets.BITBUCKET_CLOUD_TOKEN }} |
127 | 127 | TEST_EL_WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }} |
@@ -150,12 +150,3 @@ jobs: |
150 | 150 | with: |
151 | 151 | name: logs-e2e-tests-${{ matrix.provider }} |
152 | 152 | path: /tmp/logs |
153 | | - |
154 | | - - name: Report Status |
155 | | - if: ${{ always() && github.ref_name == 'main' && github.event_name == 'schedule' }} |
156 | | - uses: ravsamhq/notify-slack-action@v2 |
157 | | - with: |
158 | | - status: ${{ job.status }} |
159 | | - notify_when: "failure" |
160 | | - env: |
161 | | - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |
0 commit comments