Skip to content

Commit c8d74af

Browse files
committed
fix: run find-artifact after build to avoid over-upload
1 parent a49920a commit c8d74af

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

action.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,27 +189,37 @@ runs:
189189
shell: bash
190190
working-directory: ${{ inputs.working-directory }}
191191

192+
# Find artifact URL again before uploading, as other concurrent workflows could upload the same artifact
193+
- name: Find artifact URL again before uploading
194+
id: find-artifact-after-build
195+
uses: callstackincubator/android/.github/actions/find-artifact@v1
196+
with:
197+
name: ${{ env.ARTIFACT_NAME }}
198+
re-sign: ${{ inputs.re-sign }}
199+
github-token: ${{ inputs.github-token }}
200+
pr-number: ${{ github.event.pull_request.number }}
201+
192202
- name: Upload Artifact
193203
id: upload-artifact
194-
if: ${{ !steps.find-artifact.outputs.artifact-url || (inputs.re-sign == 'true' && github.event_name == 'pull_request') }}
204+
if: ${{ !steps.find-artifact-after-build.outputs.artifact-url || (inputs.re-sign == 'true' && github.event_name == 'pull_request') }}
195205
uses: actions/upload-artifact@v4
196206
with:
197-
name: ${{ steps.find-artifact.outputs.artifact-name || env.ARTIFACT_NAME }}
207+
name: ${{ steps.find-artifact-after-build.outputs.artifact-name || env.ARTIFACT_NAME }}
198208
path: ${{ env.ARTIFACT_PATH }}
199209
if-no-files-found: error
200210

201211
- name: Delete Old Re-Signed Artifacts
202-
if: ${{ steps.find-artifact.outputs.artifact-url && inputs.re-sign == 'true' && github.event_name == 'pull_request' }}
212+
if: ${{ steps.find-artifact-after-build.outputs.artifact-url && inputs.re-sign == 'true' && github.event_name == 'pull_request' }}
203213
run: |
204-
for ID in ${{ steps.find-artifact.outputs.artifact-ids }}; do
214+
for ID in ${{ steps.find-artifact-after-build.outputs.artifact-ids }}; do
205215
echo "Deleting artifact with ID: $ID"
206216
curl -X DELETE -H "Authorization: token ${{ inputs.github-token }}" \
207217
"https://api.github.com/repos/${{ github.repository }}/actions/artifacts/$ID"
208218
done
209219
shell: bash
210220

211221
- name: Clean Up Keystore and gradle properties (signed builds only)
212-
if: ${{ !steps.find-artifact.outputs.artifact-url && inputs.sign }}
222+
if: ${{ !steps.find-artifact-after-build.outputs.artifact-url && inputs.sign }}
213223
run: |
214224
rm $HOME/.gradle/gradle.properties
215225
rm $ANDROID_SOURCE_DIR/$APP_NAME/release.keystore
@@ -220,5 +230,5 @@ runs:
220230
uses: callstackincubator/android/.github/actions/rnef-post-build@v1
221231
with:
222232
title: Android ${{ inputs.variant }} APK for all devices
223-
artifact-url: ${{ steps.upload-artifact.outputs.artifact-url || steps.find-artifact.outputs.artifact-url }}
233+
artifact-url: ${{ steps.upload-artifact.outputs.artifact-url || steps.find-artifact-after-build.outputs.artifact-url }}
224234
github-token: ${{ inputs.github-token }}

0 commit comments

Comments
 (0)