How to use any programming language on Github Action workflow ?
Many times we need to process some data before using it in our Github workflows, but we don’t find the appropriate action.
For that, I did some research on how we can use any programming language to process our data easily & use it on Github workflow
I found this example on Github Doc :
As you see we can save some output on GITHUB_OUTPUT & use it later in
GITHUB_OUTPUT. It’s the path of a temporary file generated by the runner.
Now we will use some programming language (Dart for an example) to process some data & use it on our Github workflow
We will use an example for Bump Flutter app version using this fastlane plugin based on PR’s labels
Now this is the dart script :
We process input data by removing all labels except major, minor & patch, and split it by (,)
Then in line 16 we get environment variables & select GITHUB_OUTPUT in line 17 to get the path of the temporary file generated by the runner
After it, we open the file by Dart & write our output ({name}={value}) that we need in Github workflow
Now we will create our Github workflow & use the Dart script onto it
First, we need to use a setup for Dart lang action (line 18) (or any language used).
Then on line 21 we run the Dart script and pass PR labels as args & this script will return just the labels we need for the bump version (patch,minor, major) & in line 37 we use (${{env.parts}}) as the output of the script to use it as an input for the bump version by Fastlane plugin
Now when merging PR. The workflow will get labels & remove unused labels by Dart script & pass the output to Fastlane plugin to bump the version & push a new commit
You can use these steps on any programming language