assign-project workflow (pykale/pykale)
The assign-project workflow from pykale/pykale, explained and optimized by Latchkey.
C
CI health: C - fair
Point runs-on at Latchkey and get run de-duplication, job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the assign-project workflow from the pykale/pykale repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
workflow (.yml)
# This workflow will automatically add an issue or pull request to the project defined on lines 25 and 38.
# The project needs to be updated when we move to a new project.
# https://github.com/marketplace/actions/add-to-github-projects
# The encrypted secret key "ADD_TO_PROJECT_PAT" has been created in accordance with the guidelines provided in https://docs.github.com/en/actions/security-guides/encrypted-secrets
# In PRs, the action will only run if the PR is from pykale repository to avoid requesting secrets for forks.
name: assign-project
on:
issues:
types: [opened, labeled]
pull_request:
types: [opened, labeled]
jobs:
add-issue-to-project:
name: Add issue to project
if: |
github.event_name == 'issues' &&
github.event.action == 'opened'
runs-on: ubuntu-latest
steps:
- uses: actions/add-to-project@v1.0.2
with:
project-url: https://github.com/orgs/pykale/projects/4
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}
add-pull-request-to-project:
name: Add pull request to project
if: |
github.event_name == 'pull_request' &&
github.event.action == 'opened' &&
github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
steps:
- uses: actions/add-to-project@v1.0.2
with:
project-url: https://github.com/orgs/pykale/projects/4
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
# This workflow will automatically add an issue or pull request to the project defined on lines 25 and 38. # The project needs to be updated when we move to a new project. # https://github.com/marketplace/actions/add-to-github-projects # The encrypted secret key "ADD_TO_PROJECT_PAT" has been created in accordance with the guidelines provided in https://docs.github.com/en/actions/security-guides/encrypted-secrets # In PRs, the action will only run if the PR is from pykale repository to avoid requesting secrets for forks. name: assign-project on: issues: types: [opened, labeled] pull_request: types: [opened, labeled] concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: add-issue-to-project: timeout-minutes: 30 name: Add issue to project if: | github.event_name == 'issues' && github.event.action == 'opened' runs-on: latchkey-small steps: - uses: actions/add-to-project@v1.0.2 with: project-url: https://github.com/orgs/pykale/projects/4 github-token: ${{ secrets.ADD_TO_PROJECT_PAT }} add-pull-request-to-project: timeout-minutes: 30 name: Add pull request to project if: | github.event_name == 'pull_request' && github.event.action == 'opened' && github.event.pull_request.head.repo.full_name == github.repository runs-on: latchkey-small steps: - uses: actions/add-to-project@v1.0.2 with: project-url: https://github.com/orgs/pykale/projects/4 github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}
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. - Cancel superseded runs when a branch or PR gets a newer push.
- Add a job timeout so a hung step cannot burn hours of runner time.
This workflow runs 2 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.