@@ -16,15 +16,31 @@ jobs:
1616 - name : Checkout repository
1717 uses : actions/checkout@v5
1818
19- - name : Check for Solutions/ changes
19+ - name : Restore last processed commit
20+ id : last_commit_cache
21+ uses : actions/cache@v4
22+ with :
23+ path : .last_leetcode_commit
24+ key : leetcode-last-commit
25+
26+ - name : Load last processed commit SHA
27+ id : last_commit
28+ run : |
29+ if [ -f .last_leetcode_commit ]; then
30+ echo "last=$(cat .last_leetcode_commit)" >> $GITHUB_OUTPUT
31+ else
32+ echo "last=" >> $GITHUB_OUTPUT
33+ fi
34+
35+ - name : Check for Solutions/ changes since last run
2036 id : changes
2137 run : |
22- git fetch --depth=2 origin ${{ github.ref_name }}
23- if git rev-parse HEAD^ >/dev/null 2>&1 ; then
24- # Normal commit (has a parent)
25- git diff --name-only HEAD^ HEAD > files.txt
38+ git fetch origin ${{ github.ref_name }}
39+ if [ -n "${{ steps.last_commit.outputs.last }}" ] ; then
40+ echo "Comparing from ${{ steps.last_commit.outputs.last }} to HEAD"
41+ git diff --name-only ${{ steps.last_commit.outputs.last }}.. HEAD > files.txt
2642 else
27- # Root commit (no parent)
43+ echo "No previous commit recorded, checking current HEAD only"
2844 git show --name-only --pretty="" HEAD > files.txt
2945 fi
3046
7692 git fetch origin ${{ github.ref_name }}
7793 git rebase origin/${{ github.ref_name }}
7894
79- git push origin HEAD:${{ github.ref_name }}
95+ git push origin HEAD:${{ github.ref_name }}
96+
97+ - name : Save last processed commit
98+ if : always() && steps.changes.outputs.changed == 'true'
99+ run : |
100+ git rev-parse HEAD > .last_leetcode_commit
0 commit comments