Skip to content

✨ Add campaign mode #2254 (#2298) #76

✨ Add campaign mode #2254 (#2298)

✨ Add campaign mode #2254 (#2298) #76

name: Equinor Algolia indexers workflow
on:
workflow_dispatch:
inputs:
environment:
description: 'Environment for algolia indexers'
required: true
type: choice
options:
- development
- production
default: development
push:
branches:
- main
- staging
paths:
- 'search/**'
- '!./README.md'
- '!./.env.template'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
BUILD_OUTPUT_PATH: ${{ github.workspace }}/search
BUILD_PACKAGE_NAME: indexers.zip
BUILD_ARTIFACT_PATH: ${{ github.workspace }}/build_artifacts
jobs:
check-code:
runs-on: ubuntu-latest
environment:
name: ${{ github.event.inputs.environment || (github.ref == 'refs/heads/main' && 'production') || 'development'}}
env:
DOCKER_BUILDKIT: 1
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
- name: Install pnpm 📦
id: install-pnpm
uses: pnpm/[email protected]
with:
version: '8.5.1'
- name: Cache pnpm modules 💾
uses: actions/setup-node@v3
with:
node-version: 18
# cache: 'npm'
- name: Install dependencies 🔧
id: install-dependencies
run: |
pushd search
pnpm install
popd
- name: Run ESLint 🔎
id: lint
run: |
pnpm lint:search
- name: Run tests 🔍
id: test
run: |
pnpm search-indexers test
- name: log-errors-to-slack 📄
uses: act10ns/slack@v2
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
if: failure()
build-function-application:
needs: check-code
runs-on: ubuntu-latest
environment:
name: ${{ github.event.inputs.environment || (github.ref == 'refs/heads/main' && 'production') || 'development'}}
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
- name: Install pnpm 📦
id: install-pnpm
uses: pnpm/[email protected]
with:
version: '8.5.1'
- name: Cache pnpm modules 💾
uses: actions/setup-node@v3
with:
node-version: 18
# cache: 'npm'
- name: Install dependencies 🔧
id: install-dependencies
run: |
pushd search
npm install
popd
- name: Build ⚙
id: build-functions
run: |
pnpm search-indexers build
mkdir ${{ env.BUILD_ARTIFACT_PATH }}
pushd ${{ env.BUILD_OUTPUT_PATH }}
zip -r ${{ env.BUILD_ARTIFACT_PATH }}/${{ env.BUILD_PACKAGE_NAME }} .
popd
- name: Package Azure Function release build
id: package-artifact
uses: actions/upload-artifact@v3
with:
name: ${{ vars.AZ_ALGOLIA_FUNC_APP_NAME }}
path: ${{ env.BUILD_ARTIFACT_PATH }}
- name: log-errors-to-slack 📄
uses: act10ns/slack@v2
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
if: failure()
deploy-function-application:
environment:
name: ${{ github.event.inputs.environment || (github.ref == 'refs/heads/main' && 'production') || 'development'}}
needs: [build-function-application]
runs-on: ubuntu-latest
steps:
- name: Login to Azure 🌥️
id: login-to-azure
uses: azure/login@v1
with:
creds: ${{ secrets.ENVIS_ACTIONS_SERVICE_PRINCIPAL }}
- name: 'Create output directory'
shell: bash
run: |
mkdir ${{ env.BUILD_ARTIFACT_PATH }}
# Fetch published code
- name: Download Azure function release build
id: download-artifacts
uses: actions/download-artifact@v3
with:
name: ${{ vars.AZ_ALGOLIA_FUNC_APP_NAME }}
path: ${{ env.BUILD_ARTIFACT_PATH }}
# Deploy Azure functions code
- name: Run Azure Functions Action
id: deploy
uses: azure/functions-action@v1
with:
app-name: ${{ vars.AZ_ALGOLIA_FUNC_APP_NAME }}
package: ${{ env.BUILD_ARTIFACT_PATH }}/${{ env.BUILD_PACKAGE_NAME }}
- name: log-errors-to-slack 📄
uses: act10ns/slack@v2
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
if: failure()