Skip to content

Commit

Permalink
Merge pull request #170 from DroidKaigi/yamada-ika/fix-distribute-apk…
Browse files Browse the repository at this point in the history
…-bug

use gh-actions scripts instead of actions/download-artifact to download artifacts
  • Loading branch information
Yamada-Ika authored Jul 30, 2024
2 parents a5564b5 + dda4e34 commit 32a92e6
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- run: ./gradlew :app-android:assembleDevDebug --stacktrace

- name: Upload build outputs (APKs)
uses: actions/upload-artifact@v4.3.4
uses: actions/upload-artifact@v4
with:
name: build-outputs
path: app-android/build/outputs
Expand Down
50 changes: 47 additions & 3 deletions .github/workflows/stage-app-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,55 @@ jobs:
repository: droidkaigi/conference-app-2024
ref: gh-actions
path: gh-actions
- name: Download build outputs (APKs)
uses: actions/[email protected]
- uses: actions/[email protected]
id: get-pr
with:
name: build-outputs
script: |
const headBranch = '${{ format('{0}:{1}', github.event.workflow_run.head_repository.owner.login, github.event.workflow_run.head_branch) }}'
const { data: pulls } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
head: headBranch,
direction: 'desc',
sort: 'updated',
per_page: 1
})
if (pulls.length === 0) {
return '[halt]'
} else {
return pulls[0]
}
- uses: actions/[email protected]
id: get-artifact-id
if: steps.get-pr.outputs.result != '[halt]'
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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stage-app-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
ref: gh-actions
path: gh-actions
- name: Download build outputs (APKs)
uses: actions/download-artifact@v4.1.8
uses: actions/download-artifact@v4
with:
name: build-outputs
path: ~/build-outputs
Expand Down

0 comments on commit 32a92e6

Please sign in to comment.