-
-
Notifications
You must be signed in to change notification settings - Fork 708
118 lines (98 loc) · 4.19 KB
/
attach_build_products.yml
File metadata and controls
118 lines (98 loc) · 4.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: Attach Build Products
# Posts IPA artifact links to the PR that triggered the build.
# Only fires for pull_request triggered builds — develop pushes are handled by the
# alpha-release job in build.yml (GitHub Releases).
# workflow_dispatch builds are handled by the post-to-pr job in build.yml.
concurrency:
group: attach-${{ github.event.workflow_run.pull_requests[0].number || github.event.workflow_run.head_sha }}
cancel-in-progress: true
on:
workflow_run:
workflows: ["Build and Upload Provenance"]
types:
- completed
permissions:
contents: read
pull-requests: write
actions: read
jobs:
attach:
name: Post IPA links to PR
runs-on: ubuntu-latest
# Only run for pull_request triggered builds that succeeded.
# Develop pushes use the alpha-release job; workflow_dispatch builds use post-to-pr.
if: |
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'pull_request'
steps:
- name: Get PR info and check eligibility
id: pr
env:
GH_TOKEN: ${{ github.token }}
run: |
# Get the PR number from the workflow run's associated pull requests
PR_NUMBER=$(echo '${{ toJSON(github.event.workflow_run.pull_requests) }}' \
| jq -r '.[0].number // empty')
if [ -z "$PR_NUMBER" ]; then
echo "No associated PR found — skipping"
echo "skip=true" >> "$GITHUB_OUTPUT"
exit 0
fi
# Skip agent PRs
PR_TITLE=$(gh pr view "$PR_NUMBER" \
--repo "${{ github.repository }}" \
--json title --jq '.title' 2>/dev/null || echo "")
if echo "$PR_TITLE" | grep -q "^\[Agent\]"; then
echo "Agent PR — IPA comment not needed (uses smoke build instead)"
echo "skip=true" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "skip=false" >> "$GITHUB_OUTPUT"
echo "pr_number=$PR_NUMBER" >> "$GITHUB_OUTPUT"
- name: Post artifact links to PR
if: steps.pr.outputs.skip == 'false'
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ steps.pr.outputs.pr_number }}
run: |
RUN_ID="${{ github.event.workflow_run.id }}"
RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${RUN_ID}"
# Fetch artifact names for the completed build run
ARTIFACT_NAMES=$(gh api \
"repos/${{ github.repository }}/actions/runs/${RUN_ID}/artifacts" \
--jq '.artifacts[].name' 2>/dev/null || echo "")
ARTIFACT_LIST=""
while IFS= read -r name; do
[ -n "$name" ] && ARTIFACT_LIST="${ARTIFACT_LIST}- \`${name}\`"$'\n'
done <<< "$ARTIFACT_NAMES"
SHA="${{ github.event.workflow_run.head_sha }}"
SHORT_SHA="${SHA:0:7}"
cat > /tmp/ipa_links.md << COMMENTEOF
## 📦 IPA Builds Ready — \`${SHORT_SHA}\`
Download from the [Actions run page](${RUN_URL}).
### Available IPAs
${ARTIFACT_LIST}
> **Install:** Download the \`.ipa\`, then sideload via AltStore, SideStore, or TrollStore.
> Artifacts expire after 90 days.
COMMENTEOF
gh pr comment "$PR_NUMBER" \
--repo "${{ github.repository }}" \
--body-file /tmp/ipa_links.md 2>/dev/null || \
echo "::warning::Could not post comment to PR #${PR_NUMBER}"
- name: Notify Discord
if: steps.pr.outputs.skip == 'false'
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
PR_NUMBER: ${{ steps.pr.outputs.pr_number }}
run: |
[ -z "$DISCORD_WEBHOOK" ] && exit 0
RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}"
curl -s -H "Content-Type: application/json" -X POST "$DISCORD_WEBHOOK" \
-d "{
\"embeds\": [{
\"title\": \"📦 New Provenance Builds — PR #${PR_NUMBER}\",
\"description\": \"IPA builds ready for sideloading.\",
\"url\": \"${RUN_URL}\",
\"color\": 5814783
}]
}" 2>/dev/null || true