diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2907e73d..b99fa241 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -217,29 +217,7 @@ jobs: git config user.email "<>" - name: Commit if there are changes - run: | - # Check if the file has been changed - # Input file - 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) - - # Check if file older - if [ $TIMEDIFF -gt $OLDTIME ]; then - echo "CodeExamples.md file has not been changed" - else - echo "CodeExamples.md file has been changed. Committing changes" - # Stage the file, commit and push - git status - git add CodeExamples.md - git commit -m "Updating CodeExamples.md" - branch=${GITHUB_HEAD_REF#refs/heads/} - echo Pushing changes to branch: ${branch} - git push origin HEAD:${branch} --force > /dev/null 2>&1 - fi + run: npm run commit:guide + diff --git a/package.json b/package.json index b78c72d0..3bb3cca3 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,8 @@ "test:compute": "npm run mocha -- 'test/integration/ComputeFlow.test.ts'", "test:integration:cover": "nyc --report-dir coverage/integration --no-clean npm run test:integration", "create:guide": "chmod +x ./scripts/createCodeExamples.sh && ./scripts/createCodeExamples.sh", - "create:guide:mac": "chmod +x ./scripts/createCodeExamples-mac.sh && ./scripts/createCodeExamples-mac.sh" + "create:guide:mac": "chmod +x ./scripts/createCodeExamples-mac.sh && ./scripts/createCodeExamples-mac.sh", + "commit:guide": "chmod +x scripts/commitChanges.sh && scripts/commitChanges.sh" }, "repository": { "type": "git", diff --git a/scripts/commitChanges.sh b/scripts/commitChanges.sh new file mode 100755 index 00000000..08795f00 --- /dev/null +++ b/scripts/commitChanges.sh @@ -0,0 +1,23 @@ +# Check if the file has been changed +# Input file +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) + +# Check if file older +if [ $TIMEDIFF -gt $OLDTIME ]; then + echo "CodeExamples.md file has not been changed" +else + echo "CodeExamples.md file has been changed. Committing changes" + # Stage the file, commit and push + git status + git add CodeExamples.md + git commit -m "Updating CodeExamples.md" + branch=${GITHUB_HEAD_REF#refs/heads/} + echo Pushing changes to branch: ${branch} + git push origin HEAD:${branch} --force +fi \ No newline at end of file