Skip to content

Update Repos Data

Update Repos Data #208

Workflow file for this run

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