File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Daily Commit Push
2
+
3
+ on :
4
+ schedule :
5
+ - cron : ' 0 12 * * *'
6
+ workflow_dispatch :
7
+
8
+ jobs :
9
+ commit :
10
+ runs-on : ubuntu-latest
11
+ steps :
12
+ - name : Checkout repo
13
+ uses : actions/checkout@v3
14
+ with :
15
+ ref : main
16
+
17
+ - name : Set default env var
18
+ run : echo "skip_commit=false" >> $GITHUB_ENV
19
+
20
+ - name : Configure Git
21
+ run : |
22
+ git config user.name "irsol"
23
+ git config user.email "[email protected] "
24
+
25
+ - name : Move one staged problem to problems/
26
+ run : |
27
+ NEXT=$(find staged -mindepth 1 -maxdepth 1 -type d | sort | head -n 1)
28
+ if [ -n "$NEXT" ]; then
29
+ echo "Moving $NEXT to problems/"
30
+ mv "$NEXT" problems/
31
+ else
32
+ echo "No files left to push."
33
+ echo "skip_commit=true" >> $GITHUB_ENV
34
+ fi
35
+
36
+ - name : Commit and push if changes
37
+ if : always()
38
+ run : |
39
+ if [ "$skip_commit" = "true" ]; then
40
+ echo "Skipping commit: no files moved."
41
+ exit 0
42
+ fi
43
+
44
+ if [ -n "$(git status --porcelain)" ]; then
45
+ git add problems/
46
+ git commit -m "feat: add new solution"
47
+ git push
48
+ else
49
+ echo "No changes to commit."
50
+ fi
You can’t perform that action at this time.
0 commit comments