-
Notifications
You must be signed in to change notification settings - Fork 25
115 lines (88 loc) · 3.59 KB
/
Copy pathupdate_head.yml
File metadata and controls
115 lines (88 loc) · 3.59 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
name: Update Ghidra Sleigh
on:
schedule:
- cron: '0 0 * * 1'
# Should only be manually run on default branch (master)
workflow_dispatch:
jobs:
update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v6
with:
# Use oldest supported version for maximum script compatibility
python-version: '3.10'
- name: Run Update Script
id: head_update
run: |
# Sets some outputs. See next step
python3 scripts/update_ghidra_head.py --ci
# Need this to run further Actions on the newly created PR
# See here for more details https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#authenticating-with-github-app-generated-tokens
- uses: actions/create-github-app-token@v3
if: steps.head_update.outputs.did_update
id: generate-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Commit, push, and create PR
if: steps.head_update.outputs.did_update
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
BRANCH="cron/update-ghidra-${{ steps.head_update.outputs.short_sha }}"
# Check if PR already exists for this branch
if gh pr list --head "$BRANCH" --json number --jq '.[0].number' | grep -q .; then
echo "PR already exists for branch $BRANCH, skipping"
exit 0
fi
# Configure git
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Create branch and commit
git checkout -b "$BRANCH"
git add -A
git commit -m "$(cat <<'EOF'
Bump Ghidra HEAD commit ${{ steps.head_update.outputs.short_sha }}
Changed files:
${{ steps.head_update.outputs.changed_files }}
Commit details:
${{ steps.head_update.outputs.commit_details }}
EOF
)"
# Push branch
git push -u origin "$BRANCH"
# Build PR body using heredoc with single-quoted delimiter to prevent
# bash from interpreting backticks in the markdown content as command
# substitution. GitHub Actions expressions are expanded before bash
# processes the script, so they still get substituted.
BASE_BODY=$(cat <<'PRBODY'
Changed files:
${{ steps.head_update.outputs.changed_files }}
Commit details:
${{ steps.head_update.outputs.commit_details }}
PRBODY
)
# Add intervention warning if needed
if [ "${{ steps.head_update.outputs.needs_manual_intervention }}" = "true" ]; then
INTERVENTION=$(cat <<'PRBODY'
## :warning: Manual Intervention Required
The following files were added or deleted and may require manual CMake configuration updates:
${{ steps.head_update.outputs.intervention_details }}
### Instructions
- **New C++ sources**: Add to appropriate list in `src/setup-ghidra-source.cmake`
- **Deleted C++ sources**: Remove from `src/setup-ghidra-source.cmake`
- **New spec files**: Review if `.slaspec` files are auto-generated; other types may need manual updates
- **Deleted spec files**: Verify no longer referenced
---
PRBODY
)
PR_BODY="${INTERVENTION}${BASE_BODY}"
else
PR_BODY="$BASE_BODY"
fi
# Create PR
gh pr create \
--title "Update Ghidra HEAD to commit ${{ steps.head_update.outputs.short_sha }}" \
--body "$PR_BODY"