Skip to content

Merge pull request #174 from superfaceai/ai-agent-update #754

Merge pull request #174 from superfaceai/ai-agent-update

Merge pull request #174 from superfaceai/ai-agent-update #754

name: CI/CD
on:
pull_request:
push:
branches:
- main
jobs:
check_broken_links:
name: Check links
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '18.x'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build Documentation
run: yarn build
deploy_preview:
needs: check_broken_links
name: Deploy PR Preview
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: rlespinasse/[email protected]
name: Inject slug/short variables
- uses: bobheadxi/[email protected]
name: Start deployment
id: preview_deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: ${{ env.GITHUB_HEAD_REF_SLUG_URL }}
ref: ${{ github.head_ref }}
- uses: actions/setup-node@v3
name: Setup Node.js
with:
node-version: '18.x'
- uses: amondnet/vercel-action@v20
name: Deploy to Vercel
id: vercel_preview
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
scope: ${{ secrets.VERCEL_SCOPE }}
alias-domains: pr-{{PR_NUMBER}}-superface-docs.${{ secrets.VERCEL_DOMAIN }}
- uses: bobheadxi/[email protected]
name: Finish deployment
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
deployment_id: ${{ steps.preview_deployment.outputs.deployment_id }}
env_url: ${{ steps.vercel_preview.outputs.preview-url }}
deploy_production:
needs: check_broken_links
name: Deploy to Production
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: bobheadxi/[email protected]
name: Start deployment
id: production_deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
auto_inactive: true
env: Production
- uses: actions/setup-node@v3
name: Setup Node.js
with:
node-version: lts/*
- uses: amondnet/vercel-action@v20
name: Deploy to Vercel
id: vercel_production
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
scope: ${{ secrets.VERCEL_SCOPE }}
vercel-args: '--prod'
github-comment: false
- uses: bobheadxi/[email protected]
name: Finish deployment
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
deployment_id: ${{ steps.production_deployment.outputs.deployment_id }}
env_url: ${{ steps.vercel_production.outputs.preview-url }}
index_production:
needs: deploy_production
name: Index production to Algolia
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: echo ::set-output name=CONFIG::$(cat .github/algolia/config.json | jq -r tostring)
name: Get Scraper config
id: config
- uses: addnab/docker-run-action@v3
name: Scrape and Index docs
with:
image: algolia/docsearch-scraper
options: -e API_KEY -e APPLICATION_ID -e CONFIG
run: pipenv run python -m src.index
env:
API_KEY: ${{ secrets.ALGOLIA_ADMIN_API_KEY }}
APPLICATION_ID: ${{ secrets.ALGOLIA_APPLICATION_ID }}
CONFIG: ${{ steps.config.outputs.CONFIG }}