DEV Community

Dale Zak
Dale Zak

Posted on • Originally published at dalezak.Medium

4 3

GitHub Action to Attach Commits and Pull Requests to Trello Cards

This GitHub Action lets you easily attach GitHub commits and pull requests to a Trello card simply by including the card number in your git commit message.


GitHub Issues is such a great tool for software development teams. However if the rest of your company is already using Trello, then you are faced with the decision whether to stick with Trello or switch to GitHub Issues.

The upside of sticking with Trello is that it’s already familiar for non-developers so it’s easy for other team members to submit bugs or feature requests. The downside of GitHub is the development team often works in a silo plus it adds another tool others need to become familiar with.

So for our team I decided to stick with Trello, however quickly noticed the disconnect between commits and Trello cards.

There are some GitHub Action out there that can mirror GitHub Issues to Trello Cards, however none really did want I wanted. So I ended up writing my own GitHub Action called GitHub-Commit-To-Trello-Card.

https://github.com/marketplace/actions/github-commit-to-trello-card


Here’s a sample of what the GitHub Action looks like.

name: GitHub Commit To Trello Comment

on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - uses: dalezak/github-commit-to-trello-card@main
        with:
          trello-api-key: ${{ secrets.TRELLO_KEY }}
          trello-auth-token: ${{ secrets.TRELLO_TOKEN }}
          trello-board-id: ${{ secrets.TRELLO_BOARD }}
          trello-card-action: "Attachment"
          trello-list-name-commit: "Doing"
          trello-list-name-pr-open: "Reviewing"
          trello-list-name-pr-closed: "Testing"
Enter fullscreen mode Exit fullscreen mode

And these are what each of the action variables are.

  • trello-api-key — Trello API key, visit https://trello.com/app-key for key
  • trello-auth-token — Trello auth token, visit https://trello.com/app-key then click generate a token
  • trello-board-id — Trello board ID, visit a board then append .json to url to find id
  • trello-card-action — Trello card action, either “Comment” or “Attachment”
  • trello-list-name-commit — Trello list name for new commit, for example “Doing”, “In Progress”, etc
  • trello-list-name-pr-open — Trello list name for open pull request, for example “Reviewing”, “In Review”, etc
  • trello-list-name-pr-closed — Trello list name for closed pull request, for example “Testing”, “Done”, etc

Now to use the action simply include the card number in the git commit message.

git add .
git commit -m "Added initial login form for #751"
git push
Enter fullscreen mode Exit fullscreen mode

And voila! The commit message is magically attached to Trello card #751.

trello-card

I also setup the action to automatically move cards between lists. For example, when a pull request is opened it can move a card to “Reviewing”, “In Review”, etc, and when the pull request is closed it can move the card to “Testing”, “Done”, etc according to the trello-list-name-pr-open and trello-list-name-pr-closed variables. Enjoy!

Billboard image

Use Playwright to test. Use Playwright to monitor.

Join Vercel, CrowdStrike, and thousands of other teams that run end-to-end monitors on Checkly's programmable monitoring platform.

Get started now!

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay