Deploy Docusaurus Website #33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy Docusaurus Website | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '20' | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Build Operaton site | |
| env: | |
| TYPESENSE_API_KEY: ${{ secrets.TYPESENSE_API_KEY }} | |
| run: | | |
| npm run build || echo "Build failed, proceeding anyway if build/ exists" | |
| .github/script/release-assets.sh | |
| - name: Check if build directory exists | |
| run: | | |
| if [ ! -d "build" ]; then | |
| echo "Build directory does not exist. Exiting." | |
| exit 1 | |
| fi | |
| - name: Set up SSH key | |
| run: | | |
| mkdir -p ~/.ssh | |
| echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa | |
| chmod 600 ~/.ssh/id_rsa | |
| ssh-keyscan -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts | |
| - name: Deploy to remote server via rsync | |
| run: | | |
| rsync -avz --delete ./build/ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${{ secrets.SSH_PATH }} | |
| env: | |
| RSYNC_RSH: ssh -p ${{ secrets.SSH_PORT }} | |
| - name: Create symlink to latest release | |
| run: | | |
| TAG_NAME=$(gh api repos/operaton/operaton/releases/latest --jq .tag_name) | |
| ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} \ | |
| "ln -sfn ${{ secrets.SSH_PATH }}/reference/${TAG_NAME} ${{ secrets.SSH_PATH }}/reference/latest" | |
| - name: Run DocSearch Scraper | |
| uses: celsiusnarhwal/typesense-scraper@v2 | |
| with: | |
| # The secret containing your Typesense API key. Required. | |
| api-key: ${{ secrets.TYPESENSE_API_KEY }} | |
| # The hostname or IP address of your Typesense server. Required. | |
| host: docs.operaton.org | |
| # The port on which your Typesense server is listening. Optional. Default: 8108. | |
| port: 8108 | |
| # The protocol to use when connecting to your Typesense server. Optional. Default: http. | |
| protocol: https | |
| # The path to your DocSearch config file. Optional. Default: docsearch.config.json. | |
| config: docsearch.config.json |