- GitHub
- GitHub Actions
When developing your projects, you may need to create and deploy your application manually.
There are multiples examples where you will need to run a specific workflow on your project:
In this tutorial we will see how to set runtime parameters and manually trigger your workflows.
To be able to trigger a workflow manually we need to add the workflow_dispatch
keyword like this:
on:
workflow_dispatch:
Let’s take two examples:
These two use cases can be translated as inputs in our workflow like this:
on:
workflow_dispatch:
inputs:
flutter_version:
description: 'Framework version'
required: true
default: '2.5.3'
publish_artifacts:
description: 'Publish artifacts'
required: true
default: 'true'
As you can see above we have two inputs parameters flutter_version
and publish_artifacts
with their default values.
As I write this article the definition of booleans in the GitHub Actions is only possible using strings instead of real booleans.
Now we can apply these inputs values directly in the jobs:
jobs:
build_web:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v2
- name: Set Flutter version
uses: subosito/flutter-action@v2.2.0
with:
flutter-version: '${{ github.event.inputs.flutter_version }}'
## Build scripts here (see the complete example on GitHub)
- if: github.event.inputs.publish_artifacts == 'true'
name: Publish Artifacts
uses: actions/upload-artifact@v2
with:
name: artifacts
path: build/web
In the first case, we just pass the Flutter version as an input parameter for the subosito/flutter-action
. In the second one we use an if
statement to activate our not the publication of our artifacts.
Inside the Actions
tabs of your GitHub project, you will see a new line appearing that indicates that you can manually run your workflow:
And if you click on the Run workflow
button you will see a little window like below:
You will then be able to change the version of the Framework or disable the publication of your artifacts.
Now you are able to define your own inputs parameters to have more flexible workflows. You will find a complete example in the Github project repository.
Happy coding!
Source: