Skip to content

Commit

Permalink
Merge pull request #4632 from ESMCI/fix-docs-workflow
Browse files Browse the repository at this point in the history
Fixes docs workflow failing when no branch previews exist

Test suite:
Test baseline:
Test namelist changes:
Test status: [bit for bit, roundoff, climate changing]

Fixes [CIME Github issue #]
User interface changes?:
Update gh-pages html (Y/N)?:
  • Loading branch information
jasonb5 committed May 15, 2024
2 parents ba6f8c3 + 036cce9 commit 5129ad5
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
contents: write # for git push
name: Cleanup branch previews
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' }}
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -35,18 +35,26 @@ jobs:
run: |
pushd $GITHUB_WORKSPACE/gh-pages
for name in `ls branch/`
do
if [[ -z "$(git show-ref --quiet ${name})" ]]
then
git rm -rf branch/${name}
fi
done
if [[ -e "$GITHUB_WORKSPACE/gh-pages/branch" ]]; then
ls -la "$GITHUB_WORKSPACE/gh-pages/branch"
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
git commit -m "Clean up branch previews"
git push
for name in `ls branch/`
do
if [[ -z "$(git show-ref --quiet ${name})" ]]
then
git rm -rf branch/${name}
echo "Removed $GITHUB_WORKSPACE/gh-pages/branch/${name}"
fi
done
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
git commit -m "Clean up branch previews"
git push
fi
echo "Done cleaning branches"
build-and-deploy:
permissions:
contents: write # for peaceiris/actions-gh-pages to push
Expand Down

0 comments on commit 5129ad5

Please sign in to comment.