Add PR to project board workflow (open-telemetry/opentelemetry-python)
The Add PR to project board workflow from open-telemetry/opentelemetry-python, explained and optimized by Latchkey.
CI health: A - excellent
Point runs-on at Latchkey and get job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Add PR to project board workflow from the open-telemetry/opentelemetry-python repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: Add PR to project board
on:
pull_request_target:
types: [opened, reopened, ready_for_review]
permissions:
contents: read
jobs:
add-to-project:
name: add to project board
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
steps:
# NOTE: do NOT add an actions/checkout step here. This workflow uses
# pull_request_target (which has access to secrets) but must never
# execute code from the fork branch. See PR #4955 for context.
- uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
id: otelbot-token
with:
app-id: ${{ vars.OTELBOT_PYTHON_APP_ID }}
private-key: ${{ secrets.OTELBOT_PYTHON_PRIVATE_KEY }}
- uses: actions/add-to-project@v1.0.2
with:
project-url: https://github.com/orgs/open-telemetry/projects/88
github-token: ${{ steps.otelbot-token.outputs.token }}
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Add PR to project board on: pull_request_target: types: [opened, reopened, ready_for_review] permissions: contents: read jobs: add-to-project: timeout-minutes: 30 name: add to project board runs-on: latchkey-small if: github.event.pull_request.draft == false steps: # NOTE: do NOT add an actions/checkout step here. This workflow uses # pull_request_target (which has access to secrets) but must never # execute code from the fork branch. See PR #4955 for context. - uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6 id: otelbot-token with: app-id: ${{ vars.OTELBOT_PYTHON_APP_ID }} private-key: ${{ secrets.OTELBOT_PYTHON_PRIVATE_KEY }} - uses: actions/add-to-project@v1.0.2 with: project-url: https://github.com/orgs/open-telemetry/projects/88 github-token: ${{ steps.otelbot-token.outputs.token }}
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Add a job timeout so a hung step cannot burn hours of runner time.
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.