Reputation: 721
- name: Build Debug APK
run: ./gradlew assembleDebug
- name: Get Debug APK
uses: actions/upload-artifact@v1
with:
name: app-debug
path: app/build/outputs/apk/debug/app-debug.apk
- name: Build Signed APK
run: ./gradlew assembleRelease
- name: Sign Android release
uses: r0adkll/sign-android-release@v1
with:
releaseDirectory: app/build/outputs/apk/release
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
alias: ${{ secrets.ALIAS }}
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
- name: Get Release APK
uses: actions/upload-artifact@v1
with:
name: app-release
path: ${{ env.SIGNED_RELEASE_FILE }}
- name: Check debug apk existence
id: check_debug
uses: andstor/file-existence-action@v1
with:
files: "app-debug.apk"
- name: Missing Debug APK
if: steps.check_debug.outputs.files_exists == 'false'
uses: dawidd6/action-send-mail@v2
with:
server_address: smtp.gmail.com
server_port: 465
username: ${{secrets.MAIL_USERNAME}}
password: ${{secrets.MAIL_PASSWORD}}
subject: Github Actions job result
body: Build job of ${{github.repository}} is incomplete, Debug APK missing!
to: ${{secrets.MAIL_USERNAME}}
from: ${{secrets.MAIL_USERNAME}}
- name: Contains Debug APK
if: steps.check_debug.outputs.files_exists == 'true'
uses: dawidd6/action-send-mail@v2
with:
server_address: smtp.gmail.com
server_port: 465
username: ${{secrets.MAIL_USERNAME}}
password: ${{secrets.MAIL_PASSWORD}}
subject: Github Actions job result
body: Build job of ${{github.repository}} completed successfully, Debug APK exists!
to: ${{secrets.MAIL_USERNAME}}
from: ${{secrets.MAIL_USERNAME}}
- name: Check release apk existence
id: check_release
uses: andstor/file-existence-action@v1
with:
files: "app-release.aab"
- name: Missing Release APK
if: steps.check_release.outputs.files_exists == 'false'
uses: dawidd6/action-send-mail@v2
with:
server_address: smtp.gmail.com
server_port: 465
username: ${{secrets.MAIL_USERNAME}}
password: ${{secrets.MAIL_PASSWORD}}
subject: Github Actions job result
body: Build job of ${{github.repository}} is incomplete, Release APK missing!
to: ${{secrets.MAIL_USERNAME}}
from: ${{secrets.MAIL_USERNAME}}
- name: Contains Release APK
if: steps.check_release.outputs.files_exists == 'true'
uses: dawidd6/action-send-mail@v2
with:
server_address: smtp.gmail.com
server_port: 465
username: ${{secrets.MAIL_USERNAME}}
password: ${{secrets.MAIL_PASSWORD}}
subject: Github Actions job result
body: Build job of ${{github.repository}} completed successfully, Release APK exists!
to: ${{secrets.MAIL_USERNAME}}
from: ${{secrets.MAIL_USERNAME}}
After generating the APK files for my Android repo, I want the GitHub CI to send me an email to notify me that the artifacts are generated. So here I have an action to check if the APK name exists and regardless of the result, send me an email.
These artifacts are generated successfully but I get the emails saying they don't exist.
What went wrong in my script?
Upvotes: 2
Views: 5281
Reputation: 483
By the way, I have got a slightly different use case but needed to check if an artifact exists prior to doing some other steps.
Stumbled across this need and found no way of checking if some artifact exists. So created a new action: https://github.com/marketplace/actions/check-artifact-existence
You can add a new step that is going to expose and output denoting if an artifact exists or not by the given artifact name:
uses: xSAVIKx/artifact-exists-action@v0
id: check_coverage_artifact
with:
name: 'coverage-artifact'
Then you can use steps.check_coverage_artifact.outputs.exists
(true/false) in the conditions.
Upvotes: 4
Reputation: 12823
You're using app/build/outputs/apk/debug/app-debug.apk
as an upload path but on the other hand you're checking app-debug.apk
for existence.
Upvotes: 1