Merge branch 'padms/1692' into staging #37
This file contains 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
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() |