From 3a4da10c08595336b4a13f6d5775429d52cd1c3f Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Tue, 31 May 2022 18:06:35 +0100 Subject: [PATCH] comparing the checksum of the CodeExamples.md file to see if it has been changed before commiting --- .github/workflows/ci.yml | 12 +----------- scripts/commitChanges.sh | 16 +++++++--------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b99fa241..5fc839ce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -199,16 +199,6 @@ jobs: repository: 'oceanprotocol/ocean.js' path: 'ocean.js' ref: ${{ github.event.pull_request.head.sha }} - - - name: Create code examples file - uses: actions/cache@v2 - env: - cache-name: cache-node-modules - with: - path: ~/.npm - key: ${{ runner.os }}-lint-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: ${{ runner.os }}-lint-${{ env.cache-name }}- - - run: npm run create:guide - name: setup git config run: | @@ -216,7 +206,7 @@ jobs: git config user.name "GitHub Actions Bot" git config user.email "<>" - - name: Commit if there are changes + - name: Create Guide & Commit if there are changes run: npm run commit:guide diff --git a/scripts/commitChanges.sh b/scripts/commitChanges.sh index 3aef82d2..c8fcb8a1 100755 --- a/scripts/commitChanges.sh +++ b/scripts/commitChanges.sh @@ -1,14 +1,12 @@ # Check if the CodeExamples.md file has been changed -FILE=CodeExamples.md -# Timeframe for the comparison -OLDTIME=60 -# Get current and file times -CURTIME=$(date +%s) -FILETIME=$(stat $FILE -c %Y) -TIMEDIFF=$(expr $CURTIME - $FILETIME) +original=$(md5sum CodeExamples.md) +echo $original +npm run create:guide +new=$(md5sum CodeExamples.md) +echo $new -# Check if file older -if [ $TIMEDIFF -gt $OLDTIME ]; then +# Check if file has changed +if [ "$new" = "$original" ]; then echo "CodeExamples.md file has not been changed" else echo "CodeExamples.md file has been changed. Committing changes"