Skip to content

Commit

Permalink
Check if gh-pages branch exist
Browse files Browse the repository at this point in the history
If not, create it.
Suppress git rm return error.

Signed-off-by: Jorge Marques <[email protected]>
  • Loading branch information
gastmaier committed Jul 23, 2024
1 parent b3007b7 commit 3b3e8b3
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions .github/workflows/top-level.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ on:
push:
branches:
- main
paths:
- 'docs/**'
pull_request:
paths:
- 'docs/**'

jobs:
build-doc:
Expand Down Expand Up @@ -47,14 +43,31 @@ jobs:
contents: write

steps:
- run: |
git config --global user.name "${{ github.event.head_commit.committer.name }}"
git config --global user.email "${{ github.event.head_commit.committer.email }}"
- uses: actions/checkout@v4
- name: Create gh-pages branch
run: >
git ls-remote --exit-code --heads origin refs/heads/gh-pages ||
(
git reset --hard ;
git clean -fdx ;
git checkout --orphan gh-pages ;
git reset --hard;
git commit -m "empty" --allow-empty ;
git push origin gh-pages:gh-pages
)
- uses: actions/checkout@v4
with:
ref: 'gh-pages'
lfs: 'false'

- name: Empty gh-pages
run: |
git rm -r . --quiet
git rm -r . --quiet || true
- uses: actions/download-artifact@v4
with:
Expand All @@ -72,9 +85,7 @@ jobs:
commit=$(git rev-parse --short HEAD)
git add . >> /dev/null
git config --global user.name "$author"
git config --global user.email "$email"
git commit -m "deploy: $commit" --allow-empty
git commit -m "deploy: ${GITHUB_SHA}" --allow-empty
- name: Push to gh-pages
run: >-
Expand Down

0 comments on commit 3b3e8b3

Please sign in to comment.