Calibre’s CLI is optimised for use in CI/CD environments. You can use the CLI to automate performance testing of your sites in Calibre.
Check Command Line Interface documentation for more information about the available commands.
Detect Pull Request preview deployments from GitHub. Each time a Pull Request is deployed to a preview environment, Calibre will run a performance test and compare the results to the production environment.
1name: Calibre Pull Request Review
2on: [deployment_status]
3
4jobs:
5 # Start a new Pull Request Review.
6 # Output will be written to the GitHub Step Summary.
7 # See https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary for more info.
8
9 pr_review:
10 # Only run this job if the deployment status is successful
11 # Only complete this job if the deployment's branch corresponds to a Pull Request
12 # Optional: filter by environment name or URL - contains(github.event.deployment_status.environment_url, 'onrender.com')
13 if: github.event.deployment_status.state == 'success' && contains(github.event.deployment_status.environment_url, 'onrender.com')
14 name: Pull Request Review
15 runs-on: ubuntu-latest
16 steps:
17 - uses: actions/checkout@v4 # Required for `gh pr view`
18 - id: pr
19 env:
20 GH_TOKEN: ${{ github.token }}
21 run: |
22 echo "PR_TITLE=$(gh pr view "${{ github.ref_name }}" --json 'title' --jq '.title')" >> "$GITHUB_OUTPUT"
23 - name: Run Pull Request Review
24 id: pull_request_review
25 if: steps.pr.outputs.PR_TITLE != null
26 env:
27 CALIBRE_API_TOKEN: ${{ secrets.CALIBRE_API_TOKEN }}
28 run: |
29 echo "PULL_REQUEST_REVIEW_REPORT=$(npx calibre site create-pull-request-review \
30 --title="${{ steps.pr.outputs.PR_TITLE }}" \
31 --site="${{ secrets.CALIBRE_SITE_SLUG }}" \
32 --branch="${{ github.ref_name }}" \
33 --sha="${{ github.sha }}" \
34 --url="${{ github.event.deployment_status.environment_url }}" \
35 --waitForResult \
36 --markdown)" >> $GITHUB_OUTPUT
37 - name: Post PR comment
38 if: steps.pr.outputs.PR_TITLE != null
39 env:
40 GH_TOKEN: ${{ github.token }}
41 run: |
42 gh pr comment "${{ github.ref_name }}" --body "${{ steps.pull_request_review.outputs.PULL_REQUEST_REVIEW_REPORT }}"
43 - name: Post Job summary
44 if: steps.pr.outputs.PR_TITLE != null
45 env:
46 GH_TOKEN: ${{ github.token }}
47 run: |
48 echo "${{ steps.pull_request_review.outputs.PULL_REQUEST_REVIEW_REPORT }}" > $GITHUB_STEP_SUMMARYMerges to the main branch will trigger the workflow and create a deploy marker in Calibre.
1name: Notify Calibre of production deploy
2on:
3 push:
4 branches:
5 - main
6
7jobs:
8 build:
9 name: Notify Calibre
10 runs-on: ubuntu-latest
11 steps:
12 - name: Create deploy
13 uses: actions/setup-node@v3
14 env:
15 CALIBRE_API_TOKEN: ${{ secrets.CALIBRE_API_TOKEN }}
16 run: |
17 npx calibre site create-deploy --site=${{ secrets.CALIBRE_SITE_SLUG }} --revision=${{ env.GITHUB_SHA }} --repository https://github.com/${{ env.GITHUB_REPOSITORY }}
18 - name: Get result
19 run: echo "${{steps.set-result.outputs.result}}"On this page