Fotoware redirect workflow #10
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: Fotoware redirect workflow | |
on: | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: 'Environment for fotoware redirect' | |
required: true | |
type: choice | |
options: | |
- development | |
- production | |
default: development | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
BUILD_PACKAGE_NAME: fotoware.zip | |
BUILD_ARTIFACT_PATH: ${{ github.workspace }}/build_artifacts | |
jobs: | |
build-function-application: | |
runs-on: ubuntu-latest | |
environment: | |
name: ${{ github.event.inputs.environment }} | |
steps: | |
- name: Checkout fotoware redirect code🛎️ | |
uses: actions/checkout@v3 | |
with: | |
repository: 'equinor/energyvision-fotoware-redirect' | |
ssh-key: '${{ secrets.DEPLOY_FUNCTION_KEY }}' | |
- name: Install pnpm 📦 | |
id: install-pnpm | |
uses: pnpm/action-setup@v4 | |
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: | | |
npm install | |
- name: Build ⚙ | |
id: build-functions | |
run: | | |
pnpm build | |
mkdir ${{ env.BUILD_ARTIFACT_PATH }} | |
zip -r ${{ env.BUILD_ARTIFACT_PATH }}/${{ env.BUILD_PACKAGE_NAME }} . | |
- name: Package Azure Function release build | |
id: package-artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ vars.AZ_FOTOWARE_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 }} | |
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_FOTOWARE_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_FOTOWARE_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() |