Export Ghidra Database #484
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: Export Ghidra Database | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '0 2 * * *' | |
| env: | |
| GHIDRA_VERSION: 11.1.2 | |
| GHIDRA_DATE: 20240709 | |
| GHIDRA_SERVER: "roblab.la" | |
| GHIDRA_PROJECT_NAME: "Touhou" | |
| GHIDRA_FOLDER: "Touhou 08 - Imperishable Night" | |
| GHIDRA_FILE_NAME: "th08_v100d.exe" | |
| RE_REPO_ORG: happyhavoc | |
| RE_REPO_NAME: th08-re | |
| jobs: | |
| export-ghidra: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| include: | |
| - branch: xml | |
| type: xml | |
| - branch: main | |
| type: decomp | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # Don't use actions/checkout@v4 because hurr durr it be broken: https://github.com/actions/checkout/issues/1477 | |
| - name: Clone export repo | |
| run: | | |
| git clone "https://github.com/$RE_REPO_ORG/$RE_REPO_NAME" "$RE_REPO_NAME" | |
| if git -C "$RE_REPO_NAME" rev-parse --verify "origin/${{ matrix.branch }}" ; then | |
| # Switch to existing branch | |
| git -C "$RE_REPO_NAME" switch -c "${{ matrix.branch }}" "origin/${{ matrix.branch }}" | |
| else | |
| # Create branch | |
| git -C "$RE_REPO_NAME" switch --orphan "${{ matrix.branch }}" | |
| fi | |
| - name: Install python 3.11 | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Get ghidra | |
| run: | | |
| curl -L https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_${GHIDRA_VERSION}_build/ghidra_${GHIDRA_VERSION}_PUBLIC_${GHIDRA_DATE}.zip -o /tmp/ghidra.zip | |
| unzip -d /tmp /tmp/ghidra.zip | |
| echo /tmp/ghidra_*/support >> $GITHUB_PATH | |
| - name: Export ghidra | |
| run: | | |
| echo "$GHIDRA_SSH_AUTH" > ssh_key | |
| # Use user-maps if it exists | |
| USER_MAPS_ARG="" | |
| if [[ -e config/ghidra-user-maps.toml ]]; then | |
| USER_MAPS_ARG="--user-mappings=config/ghidra-user-maps.toml" | |
| fi | |
| python scripts/export_ghidra_database.py $USER_MAPS_ARG --username github-action --ssh-key ssh_key --program "$GHIDRA_FILE_NAME" --project-name "$GHIDRA_PROJECT_NAME" "ghidra://$GHIDRA_SERVER/$GHIDRA_PROJECT_NAME/$GHIDRA_FOLDER" "$RE_REPO_NAME" ${{ matrix.type }} | |
| rm ssh_key | |
| env: # Or as an environment variable | |
| GHIDRA_SSH_AUTH: ${{ secrets.GHIDRA_SSH_AUTH }} | |
| - name: Push export repo | |
| run: | | |
| # Use PAT to push repo | |
| git -C "$RE_REPO_NAME" remote set-url origin "https://$GH_TOKEN_PAT@github.com/$RE_REPO_ORG/$RE_REPO_NAME" | |
| git -C "$RE_REPO_NAME" push origin HEAD | |
| env: | |
| GH_TOKEN_PAT: ${{ secrets.GH_TOKEN_PAT }} |