Update Demo #374
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Automatically pull changes to the demo site from the main 'esbonio' repo. | |
name: 'Update Demo' | |
on: | |
pull_request: | |
branches: | |
- main | |
paths: | |
- '.github/workflows/update-demo.yml' | |
workflow_dispatch: | |
schedule: | |
- cron: '33 10 * * *' | |
jobs: | |
sync: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
repository: 'swyddfa/esbonio' | |
ref: 'develop' | |
path: 'esbonio' | |
- uses: actions/checkout@v4 | |
with: | |
path: 'demo' | |
- run: | | |
set -eux | |
cd demo | |
if [ $(gh pr list --json number | jq length) -gt 0 ]; then | |
gh pr checkout $(gh pr list --json number | jq '.[0].number') | |
else | |
git checkout -b "sync-$(date +%Y-%d-%m)" | |
fi | |
name: Setup branch | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- run: | | |
set -eux | |
rsync -av --delete \ | |
--exclude=.git* \ | |
--exclude=requirements.* \ | |
--exclude=.readthedocs.yaml \ | |
--exclude=.devcontainer \ | |
esbonio/lib/esbonio/tests/workspaces/demo/ demo | |
cd demo | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config user.name "github-actions[bot]" | |
git add . | |
(git commit -am "Sync demo content" && echo "changes=yes" >> $GITHUB_OUTPUT) || echo "changes=no" >> $GITHUB_OUTPUT | |
echo '```' >> $GITHUB_STEP_SUMMARY | |
git log -1 --stat >> $GITHUB_STEP_SUMMARY | |
echo '' >> $GITHUB_STEP_SUMMARY | |
echo '```' >> $GITHUB_STEP_SUMMARY | |
id: sync | |
name: Sync content | |
- run: | | |
set -eux | |
cd demo | |
git push -u origin $(git rev-parse --abbrev-ref HEAD) | |
if [ $(gh pr list --json number | jq length) -eq 0 ]; then | |
gh pr create --base main --fill | |
fi | |
name: Open/Update PR | |
if: steps.sync.outputs.changes == 'yes' && github.event_name != 'pull_request' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |