|
| 1 | +on: |
| 2 | + push: |
| 3 | + branches: ["main"] |
| 4 | + paths-ignore: |
| 5 | + - ".github/workflows/release.yml" |
| 6 | + pull_request: |
| 7 | + branches: ["main"] |
| 8 | + workflow_call: |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
| 14 | +jobs: |
| 15 | + preflight-checks: |
| 16 | + uses: ./.github/workflows/checks.yaml |
| 17 | + |
| 18 | + deploy: |
| 19 | + needs: [preflight-checks] |
| 20 | + runs-on: ubuntu-latest |
| 21 | + environment: |
| 22 | + name: ${{ github.head_ref }} |
| 23 | + url: ${{ steps.deploymentUrl.outputs.url }} |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v3 |
| 26 | + |
| 27 | + - uses: actions/cache@v3 |
| 28 | + with: |
| 29 | + path: | |
| 30 | + node_modules |
| 31 | + key: dependencies-${{ hashFiles('package-lock.json') }} |
| 32 | + restore-keys: | |
| 33 | + dependencies-${{ hashFiles('package-lock.json') }} |
| 34 | +
|
| 35 | + - uses: actions/cache@v3 |
| 36 | + with: |
| 37 | + path: | |
| 38 | + build |
| 39 | + key: build-${{ hashFiles('package-lock.json') }}-${{ github.ref }} |
| 40 | + restore-keys: | |
| 41 | + build-${{ hashFiles('package-lock.json') }}-${{ github.ref }} |
| 42 | + build-${{ hashFiles('package-lock.json') }} |
| 43 | +
|
| 44 | + - name: Login to Docker Hub |
| 45 | + uses: docker/login-action@v3 |
| 46 | + with: |
| 47 | + username: ${{ vars.DOCKERHUB_USERNAME }} |
| 48 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 49 | + |
| 50 | + - name: "Installing lttle cli" |
| 51 | + run: | |
| 52 | + curl -fsSL https://raw.githubusercontent.com/lttle-cloud/ignition/refs/heads/master/get/lttle.sh | bash |
| 53 | +
|
| 54 | + - name: "Authenticating with eu.lttle.cloud" |
| 55 | + env: |
| 56 | + LTTLE_JWT_TOKEN: ${{ secrets.LTTLE_JWT_TOKEN }} |
| 57 | + run: | |
| 58 | + lttle login --api "http://eu.lttle.cloud:5100" "$LTTLE_JWT_TOKEN"\ |
| 59 | +
|
| 60 | + - uses: actions/setup-node@v3 |
| 61 | + with: |
| 62 | + node-version: 22.18.0 |
| 63 | + - name: "Setting up environment variables into .env.production file" |
| 64 | + run: | |
| 65 | + echo "TYPESENSE_API_KEY='$TYPESENSE_API_KEY'" >> .env.production |
| 66 | +
|
| 67 | + - name: "Setting deployment url" |
| 68 | + id: deploymentUrl |
| 69 | + run: | |
| 70 | + echo "url=\"https://"$(lttle deploy --eval "env.GITHUB_HEAD_REF == 'main' ? 'docs.lttle.aifrim.com' : 'docs-' + env.GITHUB_HEAD_REF + '-lttle-aifrim.eu.lttle.host'")" >> $GITHUB_OUTPUT |
| 71 | +
|
| 72 | + # TODO: Split this into several bash functions so that we can use the dedicated docker build actions |
| 73 | + # To facilitate caching so that rebuilding will be faster |
| 74 | + # https://docs.docker.com/build/ci/github-actions/ |
| 75 | + - name: "Deploying the application" |
| 76 | + run: ./deploy.sh |
| 77 | + |
| 78 | + # NOTE: This has been added because we need to wait for the application to be fully up before proceeding |
| 79 | + # The status of the machine does not reflect the readiness of the service + machine to receive traffic |
| 80 | + # And we want the scraper to actually scrape the documentation post-deployment & readiness |
| 81 | + - name: "Waiting for the application to be ready" |
| 82 | + run: ./wait-for-app.sh |
| 83 | + |
| 84 | + - name: "Restarting the application" |
| 85 | + run: ./restart.sh scraper |
0 commit comments