GitHub (2 blogmarks)

← Blogmarks

Beej's Guide to Git

https://beej.us/guide/bggit/html/split/

I’m still exploring this. It’s always interesting to see the in-depth details of how someone thinks about using a tool like git.

Useful label-based GitHub Actions workflows

https://www.jessesquires.com/blog/2021/08/24/useful-label-based-github-actions-workflows/#updated-21-march-2022

I was looking at how others have implemented a GitHub Action to trigger a failed check on a PR when it is tagged with certain labels, such as No Merge or WIP.

I came across this blog post which included an updated code block on how to achieve this without any 3rd-party actions. This is also the simplest example I found coming in at 18 lines.

My contribution was to alter the if check to look at multiple labels:

jobs:
  do-not-merge:
    if: ${{ contains(github.event.*.labels.*.name, 'no merge') || contains(github.event.*.labels.*.name, 'wip') }}

I also printed out the labels to add a bit more detail in the action log:

    steps:
      - name: Check for label
        run: |
          echo "Pull request label prevents merging"
          echo "Labels: ${{ join(github.event.*.labels.*.name, ', ') }}"
          echo "This workflow fails so that the pull request cannot be merged"
          exit 1

TIL'd: Use Labels To Block PR Merge