Skip to content
Latchkey

Claim Issue workflow (covid19india/covid19india.github.io)

The Claim Issue workflow from covid19india/covid19india.github.io, explained and optimized by Latchkey.

A

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.

Grade your own workflow free or run it on Latchkey →
Source: covid19india/covid19india.github.io.github/workflows/claim.ymlLicense MITView source

What it does

This is the Claim Issue workflow from the covid19india/covid19india.github.io 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)
on:
  issue_comment:
    types: [created]
name: Claim Issue
jobs:
  assign:
    name: Update labels and Assign
    if: github.event.issue.pull_request == ''
      && contains(github.event.comment.body, '/claim')
      && contains(toJson(github.event.issue.labels), 'Available')
    runs-on: ubuntu-latest
    steps:
      - uses: actions/github-script@0.9.0
        with:
          github-token: ${{secrets.GITHUB_TOKEN}}
          script: |
            await github.issues.addLabels({
              issue_number: context.issue.number,
              owner: context.repo.owner,
              repo: context.repo.repo,
              labels: ['Status: Claimed']
              })
            await github.issues.removeLabel({
              issue_number: context.issue.number,
              owner: context.repo.owner,
              repo: context.repo.repo,
              name: 'Status: Available'
              })
            await github.issues.addAssignees({
              issue_number: context.issue.number,
              owner: context.repo.owner,
              repo: context.repo.repo,
              assignees: [context.payload.sender.login]
              })
            await github.issues.createComment({
              issue_number: context.issue.number,
              owner: context.repo.owner,
              repo: context.repo.repo,
              body: 'Thank you @'+context.payload.sender.login+' for claiming this issue! 🎉 \n\nPlease reference this issue when you submit your Pull Request and make sure you follow the [contributing guidelines](https://github.com/covid19india/covid19india-react/blob/master/CONTRIBUTING.md).'
            })

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

on:
  issue_comment:
    types: [created]
name: Claim Issue
jobs:
  assign:
    timeout-minutes: 30
    name: Update labels and Assign
    if: github.event.issue.pull_request == ''
      && contains(github.event.comment.body, '/claim')
      && contains(toJson(github.event.issue.labels), 'Available')
    runs-on: latchkey-small
    steps:
      - uses: actions/github-script@0.9.0
        with:
          github-token: ${{secrets.GITHUB_TOKEN}}
          script: |
            await github.issues.addLabels({
              issue_number: context.issue.number,
              owner: context.repo.owner,
              repo: context.repo.repo,
              labels: ['Status: Claimed']
              })
            await github.issues.removeLabel({
              issue_number: context.issue.number,
              owner: context.repo.owner,
              repo: context.repo.repo,
              name: 'Status: Available'
              })
            await github.issues.addAssignees({
              issue_number: context.issue.number,
              owner: context.repo.owner,
              repo: context.repo.repo,
              assignees: [context.payload.sender.login]
              })
            await github.issues.createComment({
              issue_number: context.issue.number,
              owner: context.repo.owner,
              repo: context.repo.repo,
              body: 'Thank you @'+context.payload.sender.login+' for claiming this issue! 🎉 \n\nPlease reference this issue when you submit your Pull Request and make sure you follow the [contributing guidelines](https://github.com/covid19india/covid19india-react/blob/master/CONTRIBUTING.md).'
            })
 

What changed

This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow