I referred many answers such as this and this, but none of them were satisfactory since they call another workflow directly.
on:
workflow_run:
workflows: ["Build"]
types:
- completed
Above workflow triggers when workflow is completed/succeeded.
So far, My code can handle errors better, so it'll always (I hope it to be) succeed.
Let's say:
workflow_1.yml
workflow_2.yml
I want to call workflow_2.yml
from workflow_1.yml
. This is simple and can be done with:
- name: Call another workflow
uses: ./.github/workflows/workflow_2.yml
but, can I call workflow_2.yml
like this?
jobs:
update_fork:
runs-on: ubuntu-latest
steps:
- name: Checkout Forked Repo
uses: actions/checkout@v3
# some other steps that makes condition to be true
- name: Call another workflow
run: |
# some other code
if [ $condition == "true" ]; then
# call workflow_2.yml
fi
Edit_1:
I added if statement as another step to the above code:
- if: ${{ steps.fetch.outputs.build_app == 'true' }}
uses: ./.github/workflows/android_build.yml
I'm pretty much sure by now that this will not work and hence it kept throwing this below error:
Error: Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under '/home/runner/work/wftest/wftest/.github/workflows/android_build.yml'. Did you forget to run actions/checkout before running your local action?
This is because, I need to call it from another job i.e., it is illegal to call another workflow within a step as far as I remember.