-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (56 loc) · 2.09 KB
/
manual.yml
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Update Repos Data
on:
schedule:
- cron: '0 0 * * *' # Runs every day at midnight UTC
workflow_dispatch: # Allows manual triggering of the workflow
jobs:
update-json:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
persist-credentials: true
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Install dependencies
run: npm install node-fetch
- name: Determine absolute path
id: path
run: echo "::set-output name=repo-path::$(pwd)/res/files"
- name: List directory contents before running script
run: |
mkdir -p res/files # Ensure the directory exists
ls -la res/files
- name: Run script to update repos data
run: node js/jsonUpdater.mjs jipelski ${{ steps.path.outputs['repo-path'] }}
- name: Show updated file content
run: |
echo "Showing the content of res/files/repos_data.json:"
cat res/files/repos_data.json
- name: List directory contents after running script
run: ls -la res/files
- name: Check file content after script
run: |
echo "Content of repos_data.json after script execution:"
cat res/files/repos_data.json
- name: Commit and push changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
echo "Showing git status before adding changes:"
git status
git add -f res/files/repos_data.json
echo "Showing git status after adding changes:"
git status
if ! git diff --cached --quiet; then
echo "Changes detected. Committing and pushing changes."
git commit -m 'Update repos data'
git push origin HEAD:main
else
echo "No changes to commit"
fi