-
Notifications
You must be signed in to change notification settings - Fork 0
46 lines (36 loc) · 1.42 KB
/
Copy pathauto-commit.yml
File metadata and controls
46 lines (36 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
name: Auto Commit Non-Hidden Files
on:
schedule:
- cron: '0 17 * * *' # Schedule at 5 PM UTC daily
jobs:
auto-commit:
runs-on: ubuntu-latest
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the changed files back to the repository.
contents: write
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Configure Git User
run: |
git config --global user.name "Medyan-Naser"
git config --global user.email "medyan7.naser@gmail.com"
- name: Update Non-Hidden Files
run: |
# Add a timestamp to a file to ensure there is always a change
echo "Last updated on: $(date)" > update.txt
# Stage all non-hidden files in the repository
git add *
# Use dynamic commit messages
messages=("Minor updates" "Latest changes" "Improvements made" "Adjustments and tweaks" "Updated project files" "General updates")
random_index=$((RANDOM % ${#messages[@]}))
commit_message="${messages[$random_index]}"
# Commit the changes
git commit -m "$commit_message" || echo "No changes to commit"
- name: Push Changes
env:
GH_TOKEN: ${{ secrets.GH_PAT }}
run: |
# Use the token to authenticate and push changes
git remote set-url origin https://${GH_TOKEN}@github.com/${{ github.repository }}
git push origin main