Update Ghidra Sleigh #258
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |