Deploy to a preview website #192
Workflow file for this run
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 | |
| run-name: Deploy to ${{ github.ref_name == 'master' && 'the production website' || 'a preview website' }} | |
| on: | |
| pull_request: | |
| paths: | |
| - "docs/**" | |
| - "static/**" | |
| - "src/**" | |
| - "package-lock.json" | |
| push: | |
| branches: | |
| - master | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "npm" | |
| cache-dependency-path: "package-lock.json" | |
| - name: Install Dependencies | |
| run: npm install | |
| - name: Build Docusaurus Site | |
| run: npm run build | |
| - name: Upload Build Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: docusaurus-build | |
| path: build | |
| retention-days: 1 | |
| trigger: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Set STAGE environment variable | |
| shell: bash | |
| run: | | |
| if [[ "${{ github.ref_name }}" == "master" ]]; then | |
| STAGE="production" | |
| else | |
| STAGE="preview" | |
| fi | |
| echo "STAGE=$STAGE" >> $GITHUB_ENV | |
| - name: Trigger the backend website CI | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.BACKEND_WEBSITE_TOKEN }} | |
| script: | | |
| github.rest.actions.createWorkflowDispatch({ | |
| owner: 'supertokens', | |
| repo: 'supertokens-backend-website', | |
| workflow_id: 'release-documentation-changes.yml', | |
| ref: 'master', | |
| inputs: { | |
| "run-id": `${{ github.run_id }}`, | |
| "stage": "${{ env.STAGE }}", | |
| } | |
| }) |