mirror of
https://github.com/A6-9V/MQL5-Google-Onedrive.git
synced 2026-04-10 22:30:56 +00:00
90 lines
2.7 KiB
YAML
90 lines
2.7 KiB
YAML
name: Sync to GitHub Pages
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- 'mt5/MQL5/**'
|
|
- 'docs/**'
|
|
- 'README.md'
|
|
- '.github/workflows/github-pages-sync.yml'
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
concurrency:
|
|
group: github-pages-sync-main
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
sync-to-pages:
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
PAGES_REPO: Mouy-leng/-LengKundee-mql5.github.io.git
|
|
PAGES_BRANCH: main
|
|
steps:
|
|
- name: Checkout main repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Check GitHub Pages sync configuration
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
if [[ -z "${GITHUB_TOKEN:-}" ]]; then
|
|
echo "PAGES_SYNC_ENABLED=false" >> "$GITHUB_ENV"
|
|
echo "Skipping GitHub Pages sync: GITHUB_TOKEN not available."
|
|
exit 0
|
|
fi
|
|
echo "PAGES_SYNC_ENABLED=true" >> "$GITHUB_ENV"
|
|
|
|
- name: Setup Git
|
|
if: env.PAGES_SYNC_ENABLED == 'true'
|
|
run: |
|
|
git config --global user.name "github-actions[bot]"
|
|
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
|
|
|
- name: Clone GitHub Pages repository
|
|
if: env.PAGES_SYNC_ENABLED == 'true'
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
git clone https://${GITHUB_TOKEN}@github.com/${PAGES_REPO} pages-repo
|
|
cd pages-repo
|
|
git checkout ${PAGES_BRANCH} || git checkout -b ${PAGES_BRANCH}
|
|
|
|
- name: Sync MQL5 files to GitHub Pages
|
|
if: env.PAGES_SYNC_ENABLED == 'true'
|
|
run: |
|
|
# Copy MQL5 files
|
|
mkdir -p pages-repo/mql5
|
|
cp -r mt5/MQL5/* pages-repo/mql5/ || true
|
|
|
|
# Copy documentation
|
|
mkdir -p pages-repo/docs
|
|
cp -r docs/* pages-repo/docs/ || true
|
|
|
|
# Copy README if it exists
|
|
cp README.md pages-repo/ || true
|
|
|
|
- name: Commit and push to GitHub Pages
|
|
if: env.PAGES_SYNC_ENABLED == 'true'
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
cd pages-repo
|
|
git add -A
|
|
git diff --staged --quiet || {
|
|
git commit -m "Auto-sync from MQL5-Google-Onedrive: $(date +'%Y-%m-%d %H:%M:%S')"
|
|
git push https://${GITHUB_TOKEN}@github.com/${PAGES_REPO} ${PAGES_BRANCH}
|
|
}
|
|
|
|
- name: Summary
|
|
if: env.PAGES_SYNC_ENABLED == 'true'
|
|
run: |
|
|
echo "✅ Successfully synced to GitHub Pages repository"
|
|
echo "Repository: https://github.com/${PAGES_REPO}"
|
|
echo "Branch: ${PAGES_BRANCH}"
|