-
Notifications
You must be signed in to change notification settings - Fork 246
GitHub Actions Integration
You can also run Pronto as a GitHub action.
Here's an example .github/workflows/pronto.yml
workflow file using the github_status
and github_pr
formatters and running on each GitHub PR, with pronto-rubocop
as the runner:
name: Pronto
on: [pull_request_target]
jobs:
pronto:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- run: |
git fetch --no-tags --prune --depth=10 origin +refs/heads/*:refs/remotes/origin/*
- name: Setup Ruby
uses: ruby/setup-ruby@v1
- name: Setup pronto
run: gem install pronto pronto-rubocop
- name: Run Pronto
run: PRONTO_PULL_REQUEST_ID="${{ github.event.pull_request.number }}" PRONTO_GITHUB_ACCESS_TOKEN="${{ github.token }}" pronto run -f github_status github_pr -c origin/${{ github.base_ref }}
${{ github.token }}
is scoped to the current repository, so if you want to checkout a different repository that is private you will need to provide your own PAT. e.g ${{ secrets.GitHub_PAT }} #GitHub_PAT
is a secret that contains your PAT.
"Resource not accessible by integration"
-
pull_request_target
lets you execute actions triggered by pull requests, but have access to secrets (the file available are from the main branch, not the PR) -
workflow_run
lets you run actions after other actions have completed, with access to secrets
this blog post provides details of GitHub Actions improvements for fork and pull request workflows
please use GitHub doc checkout to update git checkout according to need.
- In above pronto.yml, setting linting pipelines up with a --depth=N (maybe 10 usually?) to reduce the size of the transfer and make the clone faster.
If your workflow is using bundler
or Gemfile
in that case, you might need to use bundle exec
before pronto command.
- name: Run Pronto
run: |
PRONTO_PULL_REQUEST_ID="${{ github.event.pull_request.number }}" PRONTO_GITHUB_ACCESS_TOKEN="${{ github.token }}" bundle exec pronto run -f github_status github_pr -c origin/${{ github.base_ref }}
add pronto and pronto runners gems in Gemfile
on: [pull_request]
name: Pronto
jobs:
linters:
name: Linters
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- run: |
git fetch --no-tags --prune --depth=10 origin +refs/heads/*:refs/remotes/origin/*
- name: Setup Ruby
uses: ruby/setup-ruby@v1
- name: Ruby gem cache
uses: actions/cache@v1
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Install gems
run: |
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 10.13.0
- name: Find yarn cache location
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: JS package cache
uses: actions/cache@v1
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install packages
run: |
yarn install --pure-lockfile
- name: Run Pronto
run: |
PRONTO_PULL_REQUEST_ID="${{ github.event.pull_request.number }}" PRONTO_GITHUB_ACCESS_TOKEN="${{ github.token }}" bundle exec pronto run -f github_status github_pr -c origin/${{ github.base_ref }}