multiple docs improvements #162
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
| on: | |
| push: | |
| branches: ["main"] | |
| paths-ignore: | |
| - ".github/workflows/release.yml" | |
| pull_request: | |
| branches: ["main"] | |
| workflow_call: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| preflight-checks: | |
| uses: ./.github/workflows/checks.yaml | |
| deploy: | |
| needs: [preflight-checks] | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: ${{ github.ref_name == 'main' && 'production' || 'preview' }} | |
| url: ${{ steps.deploymentUrl.outputs.url }} | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - uses: actions/cache@v3 | |
| with: | |
| path: | | |
| node_modules | |
| key: dependencies-${{ hashFiles('package-lock.json') }} | |
| restore-keys: | | |
| dependencies-${{ hashFiles('package-lock.json') }} | |
| - uses: actions/cache@v3 | |
| with: | |
| path: | | |
| build | |
| key: build-${{ hashFiles('package-lock.json') }}-${{ github.ref }} | |
| restore-keys: | | |
| build-${{ hashFiles('package-lock.json') }}-${{ github.ref }} | |
| build-${{ hashFiles('package-lock.json') }} | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ vars.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: "Installing lttle cli" | |
| run: | | |
| curl -fsSL https://install.lttle.sh | bash | |
| - name: "Authenticating with eu.lttle.cloud" | |
| env: | |
| LTTLE_JWT_TOKEN: ${{ secrets.LTTLE_JWT_TOKEN }} | |
| run: | | |
| lttle login --api "https://eu.lttle.cloud" "$LTTLE_JWT_TOKEN" | |
| - name: "Setting deployment" | |
| id: deploymentUrl | |
| run: | | |
| url="https://"$(lttle deploy --eval "git.ref == 'main'? 'docs.lttle.cloud' : 'docs-' + env.GITHUB_HEAD_REF.toSlug() + '-lttle-aifrim.eu.lttle.host'") | |
| name="https://"$(lttle deploy --eval "git.ref == 'main'? git.ref : preview") | |
| echo "url=$url" >> $GITHUB_OUTPUT | |
| echo "name=$name" >> $GITHUB_OUTPUT | |
| # TODO: Split this into several bash functions so that we can use the dedicated docker build actions | |
| # To facilitate caching so that rebuilding will be faster | |
| # https://docs.docker.com/build/ci/github-actions/ | |
| - name: "Deploying the application" | |
| run: ./deploy.sh | |
| env: | |
| TYPESENSE_API_KEY: ${{ vars.TYPESENSE_API_KEY }} | |
| # NOTE: Apply certificate only on main branch deployments for production | |
| - name: "Apply certificate" | |
| if: github.ref_name == 'main' | |
| run: | | |
| lttle deploy ./lttle/certs.lttle.yaml | |
| # NOTE: This has been added because we need to wait for the application to be fully up before proceeding | |
| # The status of the machine does not reflect the readiness of the service + machine to receive traffic | |
| # And we want the scraper to actually scrape the documentation post-deployment & readiness | |
| - name: "Waiting for the application to be ready" | |
| run: ./wait-for-app.sh | |
| # IMPORTANT: Why do we need to wait for 30s here? | |
| - name: "Waiting for 30s for typesense-scraper to be ready" | |
| run: sleep 30s | |
| - name: "Restarting the application" | |
| run: ./restart.sh scraper |