Skip to content

Commit

Permalink
trigger the run-osp-extended-tests action on specific comment
Browse files Browse the repository at this point in the history
Signed-off-by: Evgeny Slutsky <eslutsky@redhat.com>
  • Loading branch information
eslutsky committed Jun 20, 2023
1 parent 6535cc5 commit f738ab3
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 4 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/create-new-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: new PR greeter
on:
pull_request_target:
types: [opened,reopened]

jobs:
new_pr_greeter:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Checkout forklift
uses: actions/checkout@v3

- id: codeowner
uses: SvanBoxel/codeowners-action@v1
with:
path: './.github/CODEOWNERS'

- name: fail if the commenter doesnt exists in codeowners
id: allowedaccess
run: |
echo allowed=$(echo '${{ steps.codeowner.outputs.codeowners }}' | \
jq -r '."tests/" | index("@${{ github.actor }}")') >> $GITHUB_OUTPUT
- name: Add comment to PR
uses: actions/github-script@v6
if: ${{ steps.allowedaccess.outputs.allowed == '1' }}
with:
script: |
const body = `Welcome ${{ github.actor }}, you can run extended openstack test with **/test-osp-extended** comment`;
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
})
73 changes: 69 additions & 4 deletions .github/workflows/run-osp-extended-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
name:
description: 'run e2e openstack extended tests on Self hosted runner'
workflow_call:

issue_comment:
types: [ created ]

Expand All @@ -16,18 +15,54 @@ concurrency:
# A workflow run is made up of one or more jobs that can run sequentially
jobs:
create_ovirt_runner:
if: github.event.issue.pull_request && contains(github.event.comment.body, '/test-osp-extended')
runs-on: ubuntu-latest
steps:
- name: Get PR branch
uses: xt0rted/pull-request-comment-branch@v1
id: comment-branch
- name: Set latest commit status as pending
if: always()
uses: myrotvorets/set-commit-status-action@master
with:
sha: ${{ steps.comment-branch.outputs.head_sha }}
token: ${{ secrets.GITHUB_TOKEN }}
status: pending

- name: Checkout forklift
uses: actions/checkout@v3

- id: codeowner
uses: SvanBoxel/codeowners-action@v1
with:
path: './.github/CODEOWNERS'

- name: fail if the commenter doesnt exists in codeowners
run: |
[[ $(echo '${{ steps.codeowner.outputs.codeowners }}' | \
jq -r '."tests/" | index("@${{ github.event.comment.user.login }}")') -eq 1 ]]
- name: prepare the secrets
uses: kubev2v/forkliftci/ci/prepare-ansible-secrets@v4.0
#uses: kubev2v/forkliftci/ci/prepare-ansible-secrets@v4.0
uses: eslutsky/forkliftci/ci/prepare-ansible-secrets@gh-runner-fail-early
with:
OKD_ENGINE_SECRETS: ${{ secrets.OKD_ENGINE_SECRETS }}
OKD_SSH_KEY: ${{ secrets.OKD_SSH_KEY }}

- name: provision self hosted runner
uses: kubev2v/forkliftci/ci/create-self-runner@v4.0
#uses: kubev2v/forkliftci/ci/create-self-runner@v4.0
uses: eslutsky/forkliftci/ci/create-self-runner@gh-runner-fail-early

- name: Set latest commit status as ${{ job.status }}
uses: myrotvorets/set-commit-status-action@master
if: ${{ failure() || cancelled() }}
with:
sha: ${{ steps.comment-branch.outputs.head_sha }}
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}

ci_setup:
if: github.event.issue.pull_request && contains(github.event.comment.body, '/test-osp-extended')
runs-on: self-hosted
#runs-on: ubuntu-latest
needs: create_ovirt_runner
Expand All @@ -52,7 +87,7 @@ jobs:

- name: build and setup everything
#uses: kubev2v/forkliftci/ci/build-and-setup@v4.0
uses: eslutsky/forkliftci/ci/build-and-setup@add-ssl-to-action
uses: eslutsky/forkliftci/ci/build-and-setup@gh-runner-fail-early
with:
provider_name: openstack
gh_access_token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -73,6 +108,36 @@ jobs:
with:
source_provider: openstack

- name: Get PR branch
if: always()
uses: xt0rted/pull-request-comment-branch@v1
id: comment-branch

- name: Set latest commit status as ${{ job.status }}
uses: myrotvorets/set-commit-status-action@master
if: always()
with:
sha: ${{ steps.comment-branch.outputs.head_sha }}
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}

- name: Add comment to PR
uses: actions/github-script@v6
if: always()
with:
script: |
const name = '${{ github.workflow }}';
const url = '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}';
const success = '${{ job.status }}' === 'success';
const body = `${name}: ${success ? 'succeeded ✅' : 'failed ❌'}\n${url}`;
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
})
remove_ovirt_runner:
runs-on: ubuntu-latest
if: ${{ success() || failure() || cancelled() }}
Expand Down

0 comments on commit f738ab3

Please sign in to comment.