Skip to content

Check for new commits #1515

Check for new commits

Check for new commits #1515

name: Check for new commits
on:
schedule:
- cron: '30 12 * * *'
workflow_dispatch:
inputs:
repo:
description: Ghidra GitHub repository
default: NationalSecurityAgency/ghidra
required: true
env:
GHIDRA_REPO: ${{ inputs.repo || vars.GHIDRA_REPO || 'NationalSecurityAgency/ghidra' }}
jobs:
# Ensure all steps use a common revision
check:
name: Check for new commits since last release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: ${{ env.GHIDRA_REPO }}
- name: Check for new commits
id: check
run: |
LAST_REL_NAME=$(curl --silent "https://api.github.com/repos/${{github.repository}}/releases/latest" | jq .name)
LAST_REL_COMMITID=$(echo $LAST_REL_NAME | grep -oP "\(\K\w+(?=\))")
COMMIT_HASH_SHORT=$(git rev-parse --short HEAD)
COMMIT_HASH_LONG=$(git rev-parse HEAD)
echo "Latest commit is $COMMIT_HASH_LONG"
if [[ "$LAST_REL_NAME" == *"$COMMIT_HASH_SHORT"* ]]; then
echo "No commits since last release $LAST_REL_NAME"
else
echo "Found new commits since $LAST_REL_NAME. Triggering ci."
echo "trigger=true" >> $GITHUB_OUTPUT
echo "rev=$COMMIT_HASH_LONG" >> $GITHUB_OUTPUT
echo "lastrev=$LAST_REL_COMMITID" >> $GITHUB_OUTPUT
fi
- name: Trigger build
if: steps.check.outputs.trigger
uses: benc-uk/[email protected]
with:
workflow: "Ghidra Build"
inputs: '{ "repo": "${{ env.GHIDRA_REPO }}", "rev": "${{steps.check.outputs.rev}}", "prevRev": "${{steps.check.outputs.lastrev}}" }'