Skip to content
This repository has been archived by the owner on Aug 16, 2022. It is now read-only.

chore(ci): Add ok to test flow #1035

Merged
merged 1 commit into from
Jun 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/ok_to_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Dispatch Test Command

on:
issue_comment:
types: [created]

jobs:
manual-approve:
runs-on: ubuntu-latest
steps:
- name: Slash Command Dispatch
uses: peter-evans/slash-command-dispatch@v3
with:
token: ${{ secrets.GH_CQ_BOT }}
reaction-token: ${{ secrets.GITHUB_TOKEN }}
issue-type: pull-request
commands: test
permission: write
28 changes: 25 additions & 3 deletions .github/workflows/test_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
push:
branches:
- main
repository_dispatch:
types: [test-command]
workflow_dispatch:
pull_request_target:
branches:
Expand All @@ -15,6 +17,17 @@ env:
CQ_NO_TELEMETRY: 1

jobs:
ok_to_test:
runs-on: ubuntu-latest
outputs:
status: ${{ steps.manually_approved.outputs.result }}
steps:
- name: Check if was manually approved
id: manually_approved
run: |
manually_approved=${{ github.event_name == 'repository_dispatch' && github.event.client_payload.slash_command.args.named.sha != '' && contains(github.event.client_payload.pull_request.head.sha, github.event.client_payload.slash_command.args.named.sha) }}
echo ::set-output name=result::"$manually_approved"

is_organization_member:
runs-on: ubuntu-latest
outputs:
Expand All @@ -36,9 +49,18 @@ jobs:
test_integration:
permissions:
id-token: write
contents: read # This is required for actions/checkout@v2
needs: is_organization_member
if: github.event_name != 'pull_request_target' || needs.is_organization_member.outputs.status == 'true' || github.actor == 'renovate[bot]'
contents: read
needs: [is_organization_member, manually_approved]
# Allow conditions in order
# 1. is_organization_member - for pull requests from CloudQuery employees
# 2. ok_to_test - for pull requests from external contributors (after manually approved)
# 3. `push` - when merging PRs to the main branch
# 4. `workflow_dispatch` - manually triggered from the GitHub Actions UI
if: |
(github.event_name == 'pull_request_target' && needs.is_organization_member.outputs.status == 'true') ||
(github.event_name == 'repository_dispatch' && needs.ok_to_test.outputs.status == 'true') ||
(github.event_name == 'push') ||
(github.event_name == 'workflow_dispatch')
strategy:
matrix:
dbversion: [ "postgres:10" ]
Expand Down