Skip to content

Commit

Permalink
workflow: Only create a PR if there is not one open already
Browse files Browse the repository at this point in the history
  • Loading branch information
alcarney committed Dec 10, 2024
1 parent ef31efc commit 44e44f3
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions .github/workflows/update-demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,32 @@ jobs:
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
- run: |
set -eux
rsync -av --delete \
--exclude=.git* \
--exclude=requirements.* \
--exclude=.readthedocs.yaml \
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 checkout -b "sync-$(date +%Y-%d-%m)"
git add .
(git commit -am "Sync demo content" && echo "changes=yes" >> $GITHUB_OUTPUT) || echo "changes=no" >> $GITHUB_OUTPUT
Expand All @@ -46,15 +58,19 @@ jobs:
echo '' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
id: sync
name: Sync content
name: Sync content
- run: |
set -eux
cd demo
git push -u origin "sync-$(date +%Y-%d-%m)"
gh pr create --base main --fill
name: Open PR
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 }}

0 comments on commit 44e44f3

Please sign in to comment.