Skip to content

Commit

Permalink
Update CI and recommended CI to create gh-pages
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Marques <[email protected]>
  • Loading branch information
gastmaier committed Jul 23, 2024
1 parent 79f34e0 commit eae0c82
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 14 deletions.
29 changes: 18 additions & 11 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ on: workflow_call
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -134,13 +132,24 @@ jobs:
$asset_name \
$full_asset_name
- name: Switch to gh-pages and empty it
run: |
git reset --hard
git clean -fdx
git fetch origin gh-pages
git checkout -b gh-pages origin/gh-pages
git rm -r . --quiet
- run: |
git config --global user.name "${{ github.event.head_commit.committer.name }}"
git config --global user.email "${{ github.event.head_commit.committer.email }}"
- name: Prepare gh-pages branch
run: >
git reset --hard ;
git clean -fdx ;
git ls-remote --exit-code --heads origin refs/heads/gh-pages &&
(
git fetch origin gh-pages ;
git checkout -b gh-pages origin/gh-pages ;
git rm -r . --quiet || true
) || (
git checkout --orphan gh-pages ;
git reset --hard ;
git commit -m "empty" --allow-empty
)
- uses: actions/download-artifact@v4
with:
Expand All @@ -154,8 +163,6 @@ jobs:
- name: Commit gh-pages
run: |
git add . >> /dev/null
git config --global user.name "${{ github.event.head_commit.committer.name }}"
git config --global user.email "${{ github.event.head_commit.committer.email }}"
git commit -m "deploy: ${GITHUB_SHA}" --allow-empty
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/top-level.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ jobs:
uses: ./.github/workflows/deploy.yml
needs: [build-doc, tests]
secrets: inherit
permissions:
contents: write
21 changes: 18 additions & 3 deletions docs/ci.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,30 @@ With GitHub Actions, the following workflow file is recommended:
if: github.ref == 'refs/heads/main'
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'
- name: Empty gh-pages
run: |
git rm -r . --quiet
git rm -r . --quiet || true
- uses: actions/download-artifact@v4
with:
Expand All @@ -168,8 +185,6 @@ With GitHub Actions, the following workflow file is recommended:
- name: Commit gh-pages
run: |
git add . >> /dev/null
git config --global user.name "${{ github.event.head_commit.committer.name }}"
git config --global user.email "${{ github.event.head_commit.committer.email }}"
git commit -m "deploy: ${GITHUB_SHA}" --allow-empty
- name: Push to gh-pages
Expand Down

0 comments on commit eae0c82

Please sign in to comment.