stage-app-push #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: stage-app-push | |
on: | |
workflow_run: | |
workflows: | |
- Build | |
types: | |
- completed | |
# Disable all permissions. We have to enable required permissions at job-level. | |
permissions: {} | |
jobs: | |
stage-default: | |
if: > | |
github.event.workflow_run.event == 'push' && | |
github.event.workflow_run.conclusion == 'success' | |
permissions: | |
actions: read # for listing workflow run artifacts | |
contents: read # for checkout | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | |
with: | |
repository: droidkaigi/conference-app-2023 | |
ref: gh-actions | |
path: gh-actions | |
- uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1 | |
id: get-artifact-id | |
with: | |
result-encoding: string | |
script: | | |
const { data: resp } = await github.rest.actions.listWorkflowRunArtifacts({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: ${{ github.event.workflow_run.id }} | |
}) | |
const artifact = resp.artifacts.find((a) => a.name === "build-outputs") | |
if (artifact) { | |
return artifact.id | |
} else { | |
return '[halt]' | |
} | |
- uses: ./gh-actions/actions/get-artifact | |
id: get-artifact | |
if: steps.get-artifact-id.outputs.result != '[halt]' | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
artifact-id: ${{ steps.get-artifact-id.outputs.result }} | |
path: ~/build-outputs | |
- run: > | |
unzip ${{ steps.get-artifact.outputs.archive-path }} -d ~/build-outputs && | |
rm -f ${{ steps.get-artifact.outputs.archive-path }} | |
- uses: ./gh-actions/actions/find-files | |
id: find-dev-debug-apk | |
with: | |
pattern: "~/build-outputs/**/app-android-dev-debug.apk" | |
- uses: tomoya0x00/dg-upload-app-action@eb9f76ba60198daa17c583705ebf527216e2def7 | |
id: upload | |
with: | |
app_owner_name: droidkaigi | |
api_token: ${{ secrets.DEPLOYGATE_API_TOKEN }} | |
app_file_path: ${{ fromJSON(steps.find-dev-debug-apk.outputs.paths)[0] }} | |
message: GitHub Actions have staged an artifact of ${{ github.ref }} / ${{ github.sha }} | |
distribution_find_by: name | |
distribution_id: ${{ format('staging/{0}', github.ref) }} | |
release_note: ${{ format('[main] Workflow {0}/{1} based on {2}', github.run_id , github.run_number , github.sha) }} | |
pin: false |