Skip to content

Commit

Permalink
Include action execution for PR code so that we can verify it works b…
Browse files Browse the repository at this point in the history
…efore merging into master

Signed-off-by: Adrian Orive <adrian.orive.oneca@gmail.com>
  • Loading branch information
Adirio committed Nov 20, 2020
1 parent 8685728 commit 7f0ebbc
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .github/actions/verifier/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ inputs:
github_token:
description: "the github_token provided by the actions runner"
required: true
suffix:
description: "suffix for Check Run names"
required: false
default: ""
runs:
using: docker
image: '../../../Dockerfile'
17 changes: 16 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
verify:
name: Verify PR contents
name: Verify PR contents (${{ github.repository }}:${{ github.base_ref }})
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -15,3 +15,18 @@ jobs:
uses: ./.github/actions/verifier
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

verify-pr:
name: Verify PR contents (${{ github.event.pull_request.head.repo.full_name }}:${{ github.head_ref }})
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.head_ref }}
- name: Verifier action
uses: ./.github/actions/verifier
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
suffix: (${{ github.event.pull_request.head.repo.full_name }}:${{ github.head_ref }})
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ The code that actually runs lives in [verify/cmd](/verify/cmd), while
[/verify](/verify) contains a framework for running PR description checks
from GitHub actions & uploading the result via the GitHub checks API.
This repo itself uses a "live" version of the action that always rebuilds
from the local code (master branch), which lives in
This repo itself uses two "live" version of the action that always rebuilds
from the local code (master branch) and from the PR branch, which lives in
[.github/actions/verifier](/.github/actions/verifier).
### Updating the action
Expand Down
6 changes: 6 additions & 0 deletions verify/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type ActionsEnv struct {
Repo string
Event *github.PullRequestEvent
Client *github.Client
Suffix string
}

func setupEnv() (*ActionsEnv, error) {
Expand Down Expand Up @@ -81,6 +82,7 @@ func setupEnv() (*ActionsEnv, error) {
Repo: ownerAndRepo[1],
Event: &event,
Client: client,
Suffix: os.Getenv("INPUT_SUFFIX"),
}, nil
}

Expand All @@ -104,6 +106,10 @@ func RunPlugins(plugins ...PRPlugin) ActionsCallback {
var done sync.WaitGroup

for _, plugin := range plugins {
if env.Suffix != "" {
plugin.Name += " " + env.Suffix
}

done.Add(1)
go func(plugin PRPlugin) {
defer done.Done()
Expand Down

0 comments on commit 7f0ebbc

Please sign in to comment.