Skip to content

Commit

Permalink
Use our own script to do documentation deployment
Browse files Browse the repository at this point in the history
Because the default branch is called main in both AMReX-Codes.github.io and
amrex-tutorials, there is a name conflict in our previous setup using
JamesIves/github-pages-deploy-action. So we switch to our script.
  • Loading branch information
WeiqunZhang committed May 18, 2024
1 parent cea8d36 commit 5358ccc
Showing 1 changed file with 41 additions and 8 deletions.
49 changes: 41 additions & 8 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
name: Build and Deploy
on: [push, pull_request]

concurrency:
group: ${{ github.ref }}-${{ github.head_ref }}-docs
cancel-in-progress: true

jobs:
build-and-deploy:
runs-on: ubuntu-latest
Expand All @@ -26,11 +31,39 @@ jobs:
- name: Deploy
if: github.event_name == 'push' && github.repository == 'AMReX-Codes/amrex-tutorials' && github.ref == 'refs/heads/main'
uses: JamesIves/github-pages-deploy-action@v4
with:
ssh-key: ${{ secrets.DEPLOY_KEY }}
repository-name: AMReX-Codes/AMReX-Codes.github.io
branch: main # The branch the action should deploy to.
folder: Docs/build/html # The folder the action should deploy.
target_folder: amrex/tutorials_html # The folder the action should deploy to.
clean: false # Do not remove existing files from the deploy target.
env:
SSH_KEY: ${{ secrets.DEPLOY_KEY }}
run: |
# https://blog.benoitblanchon.fr/github-action-run-ssh-commands/
echo "Configure SSH"
mkdir -p ~/.ssh/
echo "$SSH_KEY" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
cat >>~/.ssh/config <<END
Host *
IdentityFile ~/.ssh/deploy_key
StrictHostKeyChecking no
END
echo "Configure git"
git config --global user.name "$(git log -1 --pretty=format:'%an')"
git config --global user.email $(git log -1 --pretty=format:'%ae')
git config --global core.ignorecase false
DEPLOY_SOURCE=${PWD}/Docs/build/html
DEPLOY_SOURCE_HEAD=$(git rev-parse --short HEAD)
cd ..
echo "git clone AMReX-Codes.github.io"
git clone --depth=1 -b main git@github.com:AMReX-Codes/AMReX-Codes.github.io
cd AMReX-Codes.github.io/amrex/tutorials_html/
rsync -q -av --checksum --progress ${DEPLOY_SOURCE}/. .
git add --all .
if [ -n "$(git status --porcelain)" ]; then
git commit -m "Deoploying from amrex-tutorials ${DEPLOY_SOURCE_HEAD}" --no-verify
echo "git push to AMReX-Codes.github.io"
git --no-pager show HEAD
echo "Successfully completed deployment"
else
git config -l
echo "No changes to deploy"
fi

0 comments on commit 5358ccc

Please sign in to comment.