Skip to content

Sync Workflow Files to strongdog2 Master Branch #179

Sync Workflow Files to strongdog2 Master Branch

Sync Workflow Files to strongdog2 Master Branch #179

Workflow file for this run

name: Sync Workflow Files to strongdog2 Master Branch
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
sync:
runs-on: ubuntu-latest
steps:
# Delete all existing artifacts at the start of the workflow
- name: Delete Existing Artifacts
run: |
for artifact in $(gh api -X GET /repos/jman1593/strongdog2/actions/artifacts | jq -r '.artifacts[] | .id'); do
gh api -X DELETE /repos/jman1593/strongdog2/actions/artifacts/$artifact
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Checkout the source repository with sparse checkout
- name: Checkout Source Repository (master branch)
uses: actions/checkout@v3
with:
repository: jman1593/jman1593.github.io
ref: master
path: source
sparse-checkout: |
winner.html
strongdog.webp
robots.txt
intro.html
favs.html
ads.txt
about.html
signup.html
login.html
settings.html
about-page-data.js
README.md
cards-data.js
site-mapping.js
fetch-depth: 1
# Checkout the destination repository with fetch-depth 1
- name: Checkout Destination Repository (master branch)
uses: actions/checkout@v3
with:
repository: jman1593/strongdog2
ref: master
path: destination
token: ${{ secrets.TOKEN }}
fetch-depth: 1
# Copy the specified files from source to destination
- name: Copy Files
run: |
cp -r source/winner.html destination/
cp -r source/strongdog.webp destination/
cp -r source/robots.txt destination/
cp -r source/intro.html destination/
cp -r source/favs.html destination/
cp -r source/ads.txt destination/
cp -r source/about.html destination/
cp -r source/signup.html destination/
cp -r source/login.html destination/
cp -r source/settings.html destination/
cp -r source/about-page-data.js destination/
cp -r source/README.md destination/
cp -r source/cards-data.js destination/
cp -r source/site-mapping.js destination/
# Commit and push the changes to the destination repository
- name: Commit and Push Changes
run: |
cd destination
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action"
git add winner.html strongdog.webp robots.txt intro.html favs.html ads.txt about.html login.html signup.html settings.html about-page-data.js README.md cards-data.js site-mapping.js
git commit -m "Sync files from jman1593.github.io (master branch)" || echo "No changes to commit"
git push origin master
# Delete all artifacts at the end of the workflow
- name: Final Cleanup - Delete Artifacts
run: |
for artifact in $(gh api -X GET /repos/jman1593/strongdog2/actions/artifacts | jq -r '.artifacts[] | .id'); do
gh api -X DELETE /repos/jman1593/strongdog2/actions/artifacts/$artifact
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}