DEV Community

loading...
Cover image for My First Hackathon Experience

My First Hackathon Experience

cddelta profile image CDDelta Updated on ・2 min read

Having worked a few personal projects that were never finished due to scope problems, I was starved for quick, fulfilling projects to work on. And I found my calling in March when GitHub hosted their GitHub Actions Hackathon.

My First Hackathon Project

As I was working with Flutter at the time and had set up CI with GitHub Actions to build my app for me I found myself doing a lot of repeated tasks every time I wanted to trigger a build (update package.yaml, push to origin, create and push a git tag for that version etc) which I would sometimes mess up and which would lead to a failed build.

With that being the case I set out to build an Action that would do all of that work for me every time I change the version in my package.yaml.

Link to Code

GitHub logo CDDelta / dart-version-auto-tag

Automatically create tags when you update your pubspec.yaml version!

dart-version-auto-tag

This action automatically creates tags in your repository when you update your pubspec.yaml version. Use it to trigger builds automatically.

Usage

Setup a workflow that triggers on commit to your release branch to run this action.

A custom GitHub access token with repo permissions needs to be created as the provided GITHUB_TOKEN, when used, cannot trigger other workflows. See here for more info on what this means.

To create an access token, see here. Save this token as a secret on your repo and provide it to the action like below.

name: Version tag
on
  push
    branches
      - master
jobs:
  tag:
    runs-on: ubuntu-latest
    steps:
      - uses: CDDelta/dart-version-auto-tag@v1.0.1
        with:
          token: ${{ secrets.TAG_TOKEN }}
Enter fullscreen mode Exit fullscreen mode

Create another workflow that is triggered when a tag is created.

name: Build release
on
  push:
    tags:
    - 'v*
Enter fullscreen mode Exit fullscreen mode

How I built it

Before writing a single line of code, I laid out the scope of what I wanted my project to do first to make sure I don't subject myself to scope creep. Then I dove into the docs to figure out whether or not it would be possible and what kind of packages would be required. Once all that was done, I forked the GitHub Action Typescript template and set out to work!

Something I had a problem with during this hackathon was testing my Action. Initially, I would push my code onto GitHub itself, run it there, and check the logs to see if it worked! This was obviously a terrible workflow so I took a step back and reconsidered my approach.

I ended up splitting up my Action into more manageable pieces and wrote tests to run them locally. I still had to push to GitHub to test the Action end to end but the workflow was much improved.

Reflections

During this hackathon, I learnt how to write more useful tests, and documentation for users, but I have been inspired to continue hacking on more ideas in other hackathons and have joined a few more since then!

If you're looking for a quick project to work on join a hackathon! It's a great opportunity to try out new approaches and finish something.

Discussion (0)

pic
Editor guide