mirror of
https://github.com/TrianguloY/UrlChecker.git
synced 2024-09-19 20:02:16 +02:00
don't use pull_requests object (is empty for external forks)
This commit is contained in:
parent
6b2b711e1e
commit
8a9e239e36
31
.github/workflows/comment-download-link.yml
vendored
31
.github/workflows/comment-download-link.yml
vendored
@ -15,34 +15,39 @@ permissions:
|
||||
|
||||
jobs:
|
||||
comment-on-pr:
|
||||
if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.pull_requests[0] != null
|
||||
if: github.event.workflow_run.conclusion == 'success'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
- name: Post url to artifact
|
||||
timeout-minutes: 5
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
OWNER: ${{ github.repository_owner }}
|
||||
REPO: ${{ github.event.repository.name }}
|
||||
CURRENT_JOB_ID: ${{ github.run_id }}
|
||||
PREVIOUS_JOB_ID: ${{ github.event.workflow_run.id }}
|
||||
PREVIOUS_SUITE_ID: ${{ github.event.workflow_run.check_suite_id }}
|
||||
PR_NUMBER: ${{ github.event.workflow_run.pull_requests[0].number }}
|
||||
run: |
|
||||
|
||||
# get artifact id
|
||||
while true; do
|
||||
ARTIFACT_ID=$(gh api "/repos/$OWNER/$REPO/actions/runs/$PREVIOUS_JOB_ID/artifacts" --jq ".artifacts[0].id")
|
||||
if [ -n "$ARTIFACT_ID" ]; then break; fi
|
||||
# the artifact isn't available immediately, retry
|
||||
echo No artifact, will retry shortly
|
||||
sleep 10
|
||||
done
|
||||
# get artifacts
|
||||
read PR_NUMBER ARTIFACT_ID EXPIRES_AT <<< $(gh api "/repos/$OWNER/$REPO/actions/runs/$PREVIOUS_JOB_ID/artifacts" --jq '"\(.artifacts[0].name) \(.artifacts[1].id) \(.artifacts[1].expires_at)"')
|
||||
if [ "$ARTIFACT_ID" == "null" ]; then
|
||||
echo "No artifacts, (probably) not a PR, exiting"
|
||||
exit
|
||||
fi
|
||||
echo "PR NUMBER: $PR_NUMBER"
|
||||
echo "ARTIFACT ID: $ARTIFACT_ID"
|
||||
echo "EXPIRES_AT: $EXPIRES_AT"
|
||||
|
||||
# post link comment
|
||||
gh api "/repos/$OWNER/$REPO/issues/$PR_NUMBER/comments" -F body=@- <<EOF
|
||||
[Download testing apk](https://github.com/$OWNER/$REPO/suites/$PREVIOUS_SUITE_ID/artifacts/$ARTIFACT_ID)
|
||||
| [Download testing apk](https://github.com/$OWNER/$REPO/suites/$PREVIOUS_SUITE_ID/artifacts/$ARTIFACT_ID) |
|
||||
| - |
|
||||
|
||||
This unsigned apk can be installed alongside the original app and should only be used for testing the changes, not for normal usage.
|
||||
The link may expire in 90 days.
|
||||
The link will expire at $EXPIRES_AT.
|
||||
|
||||
<hr>
|
||||
|
||||
<sub>This is an automatic comment created by a [Github Action](https://github.com/$OWNER/$REPO/actions/runs/$CURRENT_JOB_ID)</sub>
|
||||
EOF
|
@ -49,7 +49,6 @@ jobs:
|
||||
uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
arguments: >
|
||||
build
|
||||
assemble${{ env.VARIANT }}
|
||||
|
||||
- name: Upload apk as artifact
|
||||
@ -58,3 +57,10 @@ jobs:
|
||||
with:
|
||||
path: ./app/build/outputs/apk/${{ env.VARIANT }}/app-${{ env.VARIANT }}.apk
|
||||
name: ${{ env.NAME }}
|
||||
|
||||
- name: Upload PR id as artifact
|
||||
if: ${{ github.event_name == 'pull_request' }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
path: /dev/null
|
||||
name: ${{ github.event.number }}
|
||||
|
Loading…
Reference in New Issue
Block a user