GitHub Actions — user input
I've been working with few CI/CD servers so far. I used Jenkins, Bamboo, Travis and TeamCity. For personal project I'm using GitHub Actions. It's easy to set up, you have the whole pipeline in VCS as a regular file and everything is in one repository.
There was one thing which I thought is missing in comparison to other CI Servers, and it is providing user input to your job. This is especially useful for releases. Often you want to have manual control over versioning. Of course, there are tools which automate the versioning, but the tool can't figure out that you are going to release a major version, so you want to have control over it.
Currently, in my work, I'm responsible for migration of one of our internal projects from Jenkins to GitHub Actions. I got to the point where I needed to migrate the release workflow and the user input is something I needed badly.
It turned out that GitHub Actions provide a way to start workflow manually and pass some input there. It's called workflow_dispatch. You can find announcing blog post here.
It's really easy to use. We just need to specify the workflow event and it's inputs like this:
on:
workflow_dispatch:
inputs:
releaseVersion:
description: "Release Version"
required: true
, then you just need to use the provided input for example when creating Pull Request with the release changes:
- name: Create Pull Request
uses: repo-sync/pull-request@v2
with:
source_branch: "release/${{ github.event.inputs.releaseVersion }}" # <- that's the one
destination_branch: "master"
pr_title: "[Release]"
pr_label: "auto-pr,release"
pr_draft: true
github_token: ${{ secrets.GITHUB_TOKEN }}
That's really convenient.