22name : Package SDKs
33
44on :
5+ workflow_call :
6+ inputs :
7+ triggered_by_callable :
8+ description : ' Check if this package grabs artifacts from new build workflow'
9+ default : false
10+ required : true
11+ type : boolean
12+ skipIntegrationTests :
13+ description : ' skip integration tests?'
14+ default : ' 0'
15+ required : false
16+ type : string
17+ create_new_branch :
18+ description : ' Check if we need to create new branch to package guids update. If working_branch set, will ignore this value. '
19+ default : ' 0'
20+ required : false
21+ type : string
22+ working_branch :
23+ description : ' If already a working in progress release branch'
24+ required : false
25+ type : string
26+ release_label :
27+ description : ' If the package is intended to run for a release, put <version>-RC## for label'
28+ required : false
29+ type : string
30+ build_run_id :
31+ description : ' run id for build_starter.yml, search for all output'
32+ required : false
33+ type : string
34+
535 workflow_dispatch :
636 inputs :
737 use_new_build :
@@ -49,26 +79,58 @@ jobs:
4979 runs-on : ubuntu-latest
5080 strategy :
5181 fail-fast : false
82+ outputs :
83+ skipIntegrationTests : ${{ steps.decide_input.outputs.skipIntegrationTests }}
5284 steps :
53- - name : Print out inputs
85+ - name : Decide inputs
86+ id : decide_input
5487 shell : bash
5588 run : |
56- echo use_new_build: ${{ github.event.inputs.use_new_build }}
57- echo skipIntegrationTests: ${{ github.event.inputs.skipIntegrationTests }}
58- echo create_new_branch: ${{ github.event.inputs.create_new_branch }}
59- echo release_label: ${{ github.event.inputs.release_label }}
60- echo working_branch: ${{ github.event.inputs.working_branch }}
61- echo download_ios_run: ${{ github.event.inputs.download_ios_run }}
62- echo download_android_run: ${{ github.event.inputs.download_android_run }}
63- echo download_linux_run: ${{ github.event.inputs.download_linux_run }}
64- echo download_macos_run: ${{ github.event.inputs.download_macos_run }}
65- echo download_windows_run: ${{ github.event.inputs.download_windows_run }}
89+ if [[ "${{ inputs.triggered_by_callable }}" == "true" ]]; then
90+ # Triggered by callable
91+ echo "::set-output name=use_new_build::'1'"
92+ echo "::set-output name=skipIntegrationTests::${{ inputs.skipIntegrationTests }}"
93+ echo "::set-output name=create_new_branch::${{ inputs.create_new_branch }}"
94+ echo "::set-output name=release_label::${{ inputs.release_label }}"
95+ echo "::set-output name=working_branch::${{ inputs.working_branch }}"
96+ echo "::set-output name=download_android_run::${{ inputs.build_run_id }}"
97+ echo "::set-output name=download_ios_run::${{ inputs.build_run_id }}"
98+ echo "::set-output name=download_linux_run::${{ inputs.build_run_id }}"
99+ echo "::set-output name=download_macos_run::${{ inputs.build_run_id }}"
100+ echo "::set-output name=download_windows_run::${{ inputs.build_run_id }}"
101+ else
102+ echo "::set-output name=use_new_build::${{ github.event.inputs.use_new_build }}"
103+ echo "::set-output name=skipIntegrationTests::${{ github.event.inputs.skipIntegrationTests }}"
104+ echo "::set-output name=create_new_branch::${{ github.event.inputs.create_new_branch }}"
105+ echo "::set-output name=release_label::${{ github.event.inputs.release_label }}"
106+ echo "::set-output name=working_branch::${{ github.event.inputs.working_branch }}"
107+ echo "::set-output name=download_android_run::${{ github.event.inputs.download_android_run }}"
108+ echo "::set-output name=download_ios_run::${{ github.event.inputs.download_ios_run }}"
109+ echo "::set-output name=download_linux_run::${{ github.event.inputs.download_linux_run }}"
110+ echo "::set-output name=download_macos_run::${{ github.event.inputs.download_macos_run }}"
111+ echo "::set-output name=download_windows_run::${{ github.event.inputs.download_windows_run }}"
112+ fi
113+
114+ - name : Print inputs
115+ shell : bash
116+ run : |
117+ echo triggered_by_callable: ${{ inputs.triggered_by_callable }}
118+ echo use_new_build: ${{ steps.decide_input.outputs.use_new_build }}
119+ echo skipIntegrationTests: ${{ steps.decide_input.outputs.skipIntegrationTests }}
120+ echo create_new_branch: ${{ steps.decide_input.outputs.create_new_branch }}
121+ echo release_label: ${{ steps.decide_input.outputs.release_label }}
122+ echo working_branch: ${{ steps.decide_input.outputs.working_branch }}
123+ echo download_android_run: ${{ steps.decide_input.outputs.download_android_run }}
124+ echo download_ios_run: ${{ steps.decide_input.outputs.download_ios_run }}
125+ echo download_linux_run: ${{ steps.decide_input.outputs.download_linux_run }}
126+ echo download_macos_run: ${{ steps.decide_input.outputs.download_macos_run }}
127+ echo download_windows_run: ${{ steps.decide_input.outputs.download_windows_run }}
66128
67129 - name : Check out base branch
68130 uses : actions/checkout@v2.3.1
69131 with :
70132 fetch-depth : 0
71- ref : ${{ github.event.inputs .working_branch }}
133+ ref : ${{ steps.decide_input.outputs .working_branch }}
72134
73135 - name : Setup Python
74136 uses : actions/setup-python@v2
@@ -80,32 +142,45 @@ jobs:
80142 run : |
81143 pip install -r scripts/gha/requirements.txt
82144
145+ - name : Generate token for GitHub API
146+ # This step is necessary because the existing GITHUB_TOKEN cannot be used inside one workflow to trigger another.
147+ #
148+ # Instead, generate a new token here, using our GitHub App's private key and App ID (saved as Secrets).
149+ #
150+ # This method is preferred over the "personal access token" solution, as the GitHub App's scope is limited to just
151+ # the firebase-cpp-sdk repository.
152+ uses : tibdex/github-app-token@v1
153+ id : generate-token
154+ with :
155+ app_id : ${{ secrets.WORKFLOW_TRIGGER_APP_ID }}
156+ private_key : ${{ secrets.WORKFLOW_TRIGGER_APP_PRIVATE_KEY }}
157+
83158 - name : Name new branch
84- if : github.event.inputs .working_branch == '' && github.event.inputs .create_new_branch == '1'
159+ if : steps.decide_input.outputs .working_branch == '' && steps.decide_input.outputs .create_new_branch == '1'
85160 run : |
86161 date_str=$(date "+%Y%m%d-%H%M%S")
87162 echo "NEW_BRANCH=new_branch-${date_str}" >> $GITHUB_ENV
88163
89164 - name : Create new branch
90- if : github.event.inputs .working_branch == '' && github.event.inputs .create_new_branch == '1'
165+ if : steps.decide_input.outputs .working_branch == '' && steps.decide_input.outputs .create_new_branch == '1'
91166 run : |
92167 git remote update
93168 git checkout -b "${NEW_BRANCH}"
94169 echo "UPDATE_LOGFILE=update_log.txt" >> $GITHUB_ENV
95170
96171 - name : Checkout working branch
97- if : github.event.inputs .working_branch != ''
172+ if : steps.decide_input.outputs .working_branch != ''
98173 run : |
99174 git remote update
100- git checkout ${{ github.event.inputs .working_branch }}
175+ git checkout ${{ steps.decide_input.outputs .working_branch }}
101176 echo "UPDATE_LOGFILE=update_log.txt" >> $GITHUB_ENV
102- echo "NEW_BRANCH=${{ github.event.inputs .working_branch }}" >> $GITHUB_ENV
177+ echo "NEW_BRANCH=${{ steps.decide_input.outputs .working_branch }}" >> $GITHUB_ENV
103178
104179 - name : Set Fetch Workflow name
105180 id : set-fetch-workflow
106181 shell : bash
107182 run : |
108- if [[ "${{ github.event.inputs .use_new_build }}" == "1" ]]; then
183+ if [[ "${{ steps.decide_input.outputs .use_new_build }}" == "1" ]]; then
109184 # all use build_starter.yml
110185 echo "::set-output name=android_yml::'build_starter.yml'"
111186 echo "::set-output name=ios_yml::'build_starter.yml'"
@@ -125,7 +200,7 @@ jobs:
125200 continue-on-error : true
126201 with :
127202 workflow : ${{ steps.set-fetch-workflow.outputs.android_yml }}
128- run_id : ${{ github.event.inputs .download_android_run }}
203+ run_id : ${{ steps.decide_input.outputs .download_android_run }}
129204 name : android_unity
130205 path : built_artifect
131206
@@ -134,7 +209,7 @@ jobs:
134209 continue-on-error : true
135210 with :
136211 workflow : ${{ steps.set-fetch-workflow.outputs.ios_yml }}
137- run_id : ${{ github.event.inputs .download_ios_run }}
212+ run_id : ${{ steps.decide_input.outputs .download_ios_run }}
138213 name : ios_unity
139214 path : built_artifect
140215
@@ -143,7 +218,7 @@ jobs:
143218 continue-on-error : true
144219 with :
145220 workflow : ${{ steps.set-fetch-workflow.outputs.linux_yml }}
146- run_id : ${{ github.event.inputs .download_linux_run }}
221+ run_id : ${{ steps.decide_input.outputs .download_linux_run }}
147222 name : linux_unity
148223 path : built_artifect
149224
@@ -152,7 +227,7 @@ jobs:
152227 continue-on-error : true
153228 with :
154229 workflow : ${{ steps.set-fetch-workflow.outputs.macos_yml }}
155- run_id : ${{ github.event.inputs .download_macos_run }}
230+ run_id : ${{ steps.decide_input.outputs .download_macos_run }}
156231 name : macos_unity
157232 path : built_artifect
158233
@@ -161,7 +236,7 @@ jobs:
161236 continue-on-error : true
162237 with :
163238 workflow : ${{ steps.set-fetch-workflow.outputs.windows_yml }}
164- run_id : ${{ github.event.inputs .download_windows_run }}
239+ run_id : ${{ steps.decide_input.outputs .download_windows_run }}
165240 name : windows_unity
166241 path : built_artifect
167242
@@ -197,7 +272,7 @@ jobs:
197272 fi
198273
199274 - name : Create PR if there is None
200- if : github.event.inputs .working_branch == '' && github.event.inputs .create_new_branch == '1'
275+ if : steps.decide_input.outputs .working_branch == '' && steps.decide_input.outputs .create_new_branch == '1'
201276 id : push-branch
202277 run : |
203278 if ! git update-index --refresh; then
@@ -287,7 +362,7 @@ jobs:
287362 trigger_integration_tests :
288363 # Trigger the integration_tests workflow.
289364 needs : [package_sdks]
290- if : (github.event.inputs .skipIntegrationTests == '0') && !cancelled() && !failure()
365+ if : (needs.package_sdks.outputs .skipIntegrationTests == '0') && !cancelled() && !failure()
291366 runs-on : ubuntu-latest
292367 steps :
293368 - name : Checkout repo
0 commit comments