-
-
Notifications
You must be signed in to change notification settings - Fork 501
Add PR level app archive #628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
740ec80
8b3564a
2871d7a
e29fd2c
a73959d
f9224ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| name: PR Archive Comment | ||
|
|
||
| on: | ||
| workflow_run: | ||
| workflows: ["PR Archive"] | ||
| types: [completed] | ||
|
|
||
| permissions: | ||
| actions: read | ||
| issues: write | ||
| pull-requests: read | ||
|
|
||
| jobs: | ||
| comment: | ||
| name: Add PR archive download link | ||
| if: github.event.workflow_run.conclusion == 'success' | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| RUN_ID: ${{ github.event.workflow_run.id }} | ||
| EVENT_PR_NUMBER: ${{ github.event.workflow_run.pull_requests[0].number }} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When the completed Useful? React with πΒ / π. |
||
|
|
||
| steps: | ||
| # This trusted workflow reads artifact metadata only. Never download or | ||
| # execute artifacts produced by the untrusted pull_request workflow. | ||
| - name: Post archive download link | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| if [[ ! "$EVENT_PR_NUMBER" =~ ^[0-9]+$ ]]; then | ||
| echo "The completed workflow run is not associated with a pull request." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| ARTIFACT=$( | ||
| gh api "repos/$GITHUB_REPOSITORY/actions/runs/$RUN_ID/artifacts" \ | ||
| --jq '.artifacts | ||
| | map(select((.expired == false) and (.name | startswith("FluidVoice-PR-")))) | ||
| | sort_by(.created_at) | ||
| | last | ||
| | [.id, .name] | ||
| | @tsv' | ||
| ) | ||
| IFS=$'\t' read -r ARTIFACT_ID ARTIFACT_NAME <<< "$ARTIFACT" | ||
|
|
||
| EXPECTED_PREFIX="FluidVoice-PR-$EVENT_PR_NUMBER-" | ||
| if [[ ! "$ARTIFACT_ID" =~ ^[0-9]+$ ]]; then | ||
| echo "No valid archive artifact was found for PR #$EVENT_PR_NUMBER." >&2 | ||
| exit 1 | ||
| fi | ||
| if [[ "$ARTIFACT_NAME" =~ ^${EXPECTED_PREFIX}([0-9a-f]{12})$ ]]; then | ||
| ARTIFACT_SHORT_SHA="${BASH_REMATCH[1]}" | ||
| else | ||
| echo "The archive artifact name does not match PR #$EVENT_PR_NUMBER." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| CURRENT_HEAD_SHA=$( | ||
| gh api "repos/$GITHUB_REPOSITORY/pulls/$EVENT_PR_NUMBER" --jq '.head.sha' | ||
| ) | ||
| if [[ "${CURRENT_HEAD_SHA:0:12}" != "$ARTIFACT_SHORT_SHA" ]]; then | ||
| echo "Skipping a superseded artifact for PR #$EVENT_PR_NUMBER." | ||
| exit 0 | ||
| fi | ||
|
|
||
| ARTIFACT_URL="https://github.com/$GITHUB_REPOSITORY/actions/runs/$RUN_ID/artifacts/$ARTIFACT_ID" | ||
| RUN_URL="https://github.com/$GITHUB_REPOSITORY/actions/runs/$RUN_ID" | ||
| APP_NAME="FluidVoice #$EVENT_PR_NUMBER" | ||
| MARKER='<!-- fluidvoice-pr-archive -->' | ||
| BODY=$(cat <<EOF | ||
| $MARKER | ||
| ### FluidVoice PR build ready | ||
|
|
||
| [Download **$ARTIFACT_NAME**]($ARTIFACT_URL) | ||
|
|
||
| The artifact contains the ad-hoc-signed app ZIP, Xcode archive, build manifest, and installation instructions. It expires 5 days after the build. | ||
|
|
||
| #### Install the app | ||
|
|
||
| 1. Extract the downloaded artifact, then extract **FluidVoice-PR-$EVENT_PR_NUMBER.app.zip**. | ||
| 2. Move **$APP_NAME.app** into the **/Applications** folder. | ||
| 3. Open Terminal and remove the download quarantine marker: | ||
|
|
||
| xattr -dr com.apple.quarantine "/Applications/$APP_NAME.app" | ||
|
Comment on lines
+83
to
+85
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For external-contributor PRs, this trusted bot comment is posted for an app archive built from the PR's untrusted code, but the install steps tell reviewers to strip Gatekeeper quarantine with Useful? React with πΒ / π. |
||
|
|
||
| 4. In Applications, Control-click **$APP_NAME.app** and choose **Open**. | ||
| 5. If macOS still blocks it, open **System Settings β Privacy & Security**, click **Open Anyway**, and confirm. | ||
|
|
||
| This build has its own app identity, so its permissions are separate from the release version of FluidVoice. | ||
|
|
||
| [View workflow run]($RUN_URL) | ||
| EOF | ||
| ) | ||
|
|
||
| COMMENT_ID=$( | ||
| gh api --paginate \ | ||
| "repos/$GITHUB_REPOSITORY/issues/$EVENT_PR_NUMBER/comments" \ | ||
| --jq '.[] | select(.body | contains("<!-- fluidvoice-pr-archive -->")) | .id' \ | ||
| | sed -n '1p' | ||
| ) | ||
|
|
||
| if [[ -n "$COMMENT_ID" ]]; then | ||
| gh api --method PATCH \ | ||
| "repos/$GITHUB_REPOSITORY/issues/comments/$COMMENT_ID" \ | ||
| -f body="$BODY" \ | ||
| >/dev/null | ||
| else | ||
| gh api --method POST \ | ||
| "repos/$GITHUB_REPOSITORY/issues/$EVENT_PR_NUMBER/comments" \ | ||
| -f body="$BODY" \ | ||
| >/dev/null | ||
| fi | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the archive workflow cancels in-progress runs on new commits and this job only runs after successful conclusions, a PR that already has a build-ready comment keeps linking the older artifact whenever the next archive is cancelled or fails. The later current-head check prevents posting superseded artifacts, but these non-success paths never update or remove the existing marker, so testers can download an app for a previous PR head; let this workflow handle completed failures/cancellations or mark the existing comment stale on synchronize.
Useful? React with πΒ / π.