Check for new commits #1164
This file contains 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: Check for new commits | |
on: | |
schedule: | |
- cron: '30 12 * * *' | |
workflow_dispatch: | |
inputs: {} | |
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@v3 | |
with: | |
repository: NationalSecurityAgency/Ghidra | |
- 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" | |
token: ${{secrets.PAT_TOKEN}} | |
inputs: '{ "rev": "${{steps.check.outputs.rev}}", "prevRev": "${{steps.check.outputs.lastrev}}" }' |