Skip to content

Commit

Permalink
feat: use wiby test label as a trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
dominykas committed Sep 27, 2021
1 parent 9123ee7 commit 0e425f5
Showing 1 changed file with 33 additions and 10 deletions.
43 changes: 33 additions & 10 deletions .github/workflows/wiby.yaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,61 @@
name: wiby

on:
issue_comment:
types: [ created ]
pull_request:
types: [ labeled ]

env:
WIBY_CHECK_NAME: "wiby"
WIBY_NODE_VERSION: 14

jobs:

permissions:
status:

runs-on: ubuntu-latest

if: ${{ github.event.issue.pull_request && startsWith(github.event.comment.body, 'wiby ') && (github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'COLLABORATOR') }}
if: ${{ github.event.label.name == 'wiby test' }}

outputs:
in_progress: ${{ steps.checks_by_status.outputs.in_progress }}
queued: ${{ steps.checks_by_status.outputs.queued }}
completed: ${{ steps.checks_by_status.outputs.completed }}

steps:
- run: 'echo "Author association: ${{ github.event.comment.author_association }}"'
- name: Get status
uses: octokit/request-action@v2.x
with:
route: GET /repos/:repository/commits/:ref/check-runs
repository: ${{ github.event.repository.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
mediaType: |
previews:
- antiope
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
id: pr_status

- name: Count wiby status check by their status
run: |
jq -r '.check_runs | map(select(.name=="wiby")) | group_by(.status) | map("::set-output name=" + .[0].status + "::" + (length | tostring)) | join("\n")' << EOF
${{ steps.pr_status.outputs.data }}
EOF
id: checks_by_status

test:

runs-on: ubuntu-latest

needs: permissions
needs: status

if: ${{ startsWith(github.event.comment.body, 'wiby test') }}
if: ${{ !needs.status.outputs.in_progress && !needs.status.outputs.queued }}

steps:

- name: Load PR
uses: octokit/request-action@v2.x
with:
route: ${{ github.event.issue.pull_request.url }}
route: ${{ github.event.pull_request.url }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
id: load_pr
Expand Down Expand Up @@ -119,9 +142,9 @@ jobs:

runs-on: ubuntu-latest

needs: permissions
needs: status

if: ${{ startsWith(github.event.comment.body, 'wiby result') }}
if: ${{ needs.status.outputs.in_progress }}

steps:

Expand Down

0 comments on commit 0e425f5

Please sign in to comment.