Skip to content

Commit

Permalink
added docs deploy to ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Petr Gadorek committed Dec 11, 2024
1 parent a4cc979 commit 91e79ed
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions .github/workflows/build_docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ on:
workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-20.04
build-and-deploy-docs:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
Expand All @@ -36,10 +36,40 @@ jobs:
rm -rf ./esp-docs-mdbook
mdbook build
zip -r docs.zip ./book/
tar -czf docs.tar.gz ./book/
- name: Upload docs artifact
uses: actions/upload-artifact@v4
with:
name: eim-docs
path: docs/docs.zip
if-no-files-found: error

- name: Setup SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.DOCS_PROD_PRIVATEKEY }}" | base64 -d > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
echo "StrictHostKeyChecking no" > ~/.ssh/config
ssh-keyscan -H ${{ secrets.DOCS_PROD_SERVER }} >> ~/.ssh/known_hosts
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
- name: Create remote directory
run: ssh -o BatchMode=yes ${{ secrets.DOCS_PROD_SERVER_USER }}@${{ secrets.DOCS_PROD_SERVER }} "mkdir -p ${{ secrets.DOCS_PROD_PATH }}"

- name: Copy tarball to server
run: |
scp -B docs/docs.tar ${{ secrets.DOCS_PROD_SERVER_USER }}@${{ secrets.DOCS_PROD_SERVER }}:${{ secrets.DOCS_PROD_PATH }}/docs.tar
- name: Extract and cleanup
run: |
TARBALL_NAME=$(basename docs/docs.tar)
ssh -o BatchMode=yes ${{ secrets.DOCS_PROD_SERVER_USER }}@${{ secrets.DOCS_PROD_SERVER }} "cd ${{ secrets.DOCS_PROD_PATH }} && \
rm -rf ./*/${{ github.event.inputs.version }} && \
tar -zxvf ${TARBALL_NAME} && \
rm ${TARBALL_NAME}"
- name: Cleanup SSH key
if: always()
run: rm -f ~/.ssh/id_rsa

0 comments on commit 91e79ed

Please sign in to comment.