How to deploy react-native app all in one click-Part1
I could release Live or QA version according to a prefix of the repository tag.
However tagged repository can’t access Github cache and it’s mean that I can’t improve deploying speed.
So I am creating new deploying flow with a manual workflow.
And new workflow will enable to deploy Live or QA version without modifying config files.
workflow_dispatch
workflow_dispatch is only way to run workflow manually without creating a release.
Create manual workflow
You can make manual workflow with workflow_dispatch instead of release.
on:
workflow_dispatch:
Input values
You can specify or input values to use for workflows and the value can have boolean or string.
workflow_dispatch:
inputs:
- Boolean
I get a boolean value to specify if API server is Live or Development.
inputs:
isDevelopment:
description: '개발'
type: boolean
required: true
default: true
isDevelopment is input name.
description is a text to indicate what your input value for.
type is input value type, type can be boolea, string… for more types read Input Contexts.
And the input will be displayed on Workflows UI like this.
- String
I also appended a string value to print developer’s comment on Slack message.
inputs:
comment:
description: '남길말'
required: false
There is no type, but don’t worry, default type is string. And string input will be appeared like this.
Using input values
We are ready to get some values, so how can you access the value?
${{ github.event.inputs.isDevelopment }}
You can access input values under github.event.inputs.
You can use this value for specifying what workflow you will run like this.
android-qa:
if: ${{ github.event.inputs.isDevelopment == 'true' }}
Something weird? yes inspite we get boolean input value, it is not boolean.
So you have to compare the value with ‘true’ not true.
workflow_call
I dont’ like long source code, of course workflow file too.
Therefore I wanted to split it to iOS and Android workflow files.
Fortunately Github support the feature to run other workflows from a workflow.
Create callable workflow
To run other workflow, you should create callable workflow.
on:
workflow_call:
workflow_call can be called from another workflow.
Define input values
workflow_call also provides inputs, it is for getting values from caller workflow.
inputs:
isDevelopment:
type: boolean
required: true
comment:
type: string
required: false
default: '수정했고잉 ~ 'type: string
Call workflow
- uses
To call another workflow, you should use the keyword ‘uses’.
You would already saw it, at checkout action.
uses: olulo/kickgoing/.github/workflows/deploy-android-all-in-one.yml@master
To run your callable workflow, you have to push it first.
And you must input branch at end of workflow path.
You can’t run local workflow like this.
uses: ./github/workflows/deploy-android-all-in-one.yml
- with
To pass values or specify input values, you should use the keyword ‘with’.
with:
isDevelopment: ${{ github.event.inputs.isDevelopment == 'true' }}
comment: ${{ github.event.inputs.comment }}
As I already mentioned before, you should know boolean input value is not have boolean. You have to compare it with ‘true’, else you will get a weird error.
Actions
Don’t forget to push or merge to your main master branch first, else you can’t see your workflow on Actions.
Find your workflow
You can find your workflow at Actions menu.
Run workflow
When click Run workflow, you can your manual workflow UI. And you can select target branch also. If you select a branch doesn’t have your workflow, UI will be disappeared.
required: falsedefault: '수정했고잉 ~ '
There is no description, because it doesn’t provides UI.
to be continue in Part2