Skip to content

Create 00.jpg

Create 00.jpg #35

Workflow file for this run

name: Update Images
on:
push:
paths:
- 'gallery/pictures/**' # Trigger when any file in the pictures directory changes
workflow_dispatch: # Allows manual trigger from the GitHub UI
jobs:
update-images-js:
runs-on: ubuntu-latest
permissions:
contents: write # Ensure this workflow has permission to write to the repository
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: master # Change 'master' to 'main' if that's your default branch
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18'
- name: List directory structure
run: |
pwd # Print the current directory
ls -la # List all files and folders in the current directory
ls -la gallery/pictures/ # List all files in the pictures directory
- name: Run gallery/updateMosaic.js
run: |
node gallery/updateMosaic.js # Run the script to update images.js
- name: Verify gallery/images.js
run: cat gallery/images.js # Check the content of images.js after running the script
- name: Check if gallery/images.js was updated
run: |
echo "Checking for changes in images.js..."
if git diff --quiet; then
echo "No changes detected in images.js."
else
echo "Changes detected in images.js."
fi
- name: Commit and push if changed
run: |
git config --global user.name 'GitHub Action'
git config --global user.email 'action@github.com'
# Check if images.js exists and is not empty before adding
if [[ -f gallery/images.js && -s gallery/images.js ]]; then
git add gallery/images.js
git diff --quiet && git diff --staged --quiet || (git commit -m "Update images.js [skip ci]" && git push)
else
echo "images.js is missing or empty, skipping commit."
fi