Skip to content

Instantly share code, notes, and snippets.

@logickoder
Created June 18, 2025 09:40
Show Gist options
  • Save logickoder/bf45f0d25a95e4b921675dfb4f4d6cd5 to your computer and use it in GitHub Desktop.
Save logickoder/bf45f0d25a95e4b921675dfb4f4d6cd5 to your computer and use it in GitHub Desktop.
Download artifact from previous successful workflow of the same branch
name: Distribute Latest APK to Firebase
on:
workflow_dispatch:
permissions:
actions: read
contents: read
jobs:
distribute:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install GitHub CLI
run: |
sudo apt-get update
sudo apt-get install -y gh jq
- name: Get latest successful build run ID
id: get_run
run: |
run_id=$(gh run list --workflow build.yml --branch ${{ github.ref_name }} --json conclusion,databaseId -L 10 | jq '[.[] | select(.conclusion=="success")][0].databaseId')
echo "run_id=$run_id" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ github.token }}
- name: Download latest build artifact
run: |
gh run download ${{ steps.get_run.outputs.run_id }} -n app -D ./app-artifact
env:
GH_TOKEN: ${{ github.token }}
- name: Upload to Firebase App Distribution
uses: wzieba/Firebase-Distribution-Github-Action@v1
with:
appId: ${{ secrets.APP_ID }}
serviceCredentialsFileContent: ${{ secrets.GCP_CREDENTIAL }}
groups: Dev
file: ./app-artifact/app-release.apk
@logickoder
Copy link
Author

Assumptions (you can change when using in your workflow):

  • The workflow we are looking through is named build.yml
  • It only checks for workflow runs in the same branch that this current workflow is being run in
  • The artifact it downloads is named app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment