Delete comments over API #96
Workflow file for this run
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: Deploy JamComments API to Azure Functions | |
on: | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: 'Name of environment to deploy (staging, prod)' | |
required: true | |
default: 'staging' | |
fullDeployment: | |
description: 'Whether to do a full deployment or not' | |
required: true | |
default: 'false' | |
push: | |
branches: | |
- dev | |
- master | |
paths: | |
- 'infra/azure/apps/api/**' | |
- '.github/workflows/azure-jam-comments-api.yml' | |
- 'AzureCommentsApiGet/**' | |
- 'AzureCommentsApiPost/**' | |
- 'AzureCommentsApiNotify/**' | |
- 'AzureHealthCheck/**' | |
- 'sql/**' | |
- 'src/**' | |
- 'test/**' | |
- 'yarn.lock' | |
pull_request: | |
types: [opened, synchronize] | |
paths: | |
- 'infra/azure/apps/api/**' | |
- '.github/workflows/azure-jam-comments-api.yml' | |
- 'AzureCommentsApiGet/**' | |
- 'AzureCommentsApiPost/**' | |
- 'AzureCommentsApiNotify/**' | |
- 'AzureHealthCheck/**' | |
- 'sql/**' | |
- 'src/**' | |
- 'test/**' | |
- 'yarn.lock' | |
env: | |
AZURE_FUNCTIONAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root | |
NODE_VERSION: '20.x' # set this to the node version to use (supports 8.x, 10.x, 12.x) | |
fullDeployment: ${{ github.event.inputs.fullDeployment || 'false' }} | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
setupEnv: | |
name: Set up environments | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: setup environment variables | |
id: setupEnv | |
run: | | |
echo "Setup environment and secrets" | |
if [ "${{ github.event.inputs.environment }}" = "staging" ] || [ "${{ github.ref }}" = "refs/heads/dev" ]; then | |
echo "::set-output name=environment::staging" | |
echo "::set-output name=githubEnvironment::Development" | |
elif [ "${{ github.event.inputs.environment }}" = "prod" ] || [ "${{ github.ref }}" = "refs/heads/master" ]; then | |
echo "::set-output name=environment::prod" | |
echo "::set-output name=githubEnvironment::Production" | |
fi | |
outputs: | |
environment: ${{ steps.setupEnv.outputs.environment }} | |
githubEnvironment: ${{ steps.setupEnv.outputs.githubEnvironment }} | |
name: jamcomments-${{ steps.setupEnv.outputs.environment }}-eus-fapp | |
build-and-test: | |
name: Build app and test | |
environment: ${{ needs.setupEnv.outputs.githubEnvironment }} | |
concurrency: ${{ needs.setupEnv.outputs.name }} | |
needs: | |
- setupEnv | |
env: | |
environment: ${{ needs.setupEnv.outputs.environment }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: 'Checkout GitHub Action' | |
uses: actions/checkout@v4 | |
- name: Setup Node ${{ env.NODE_VERSION }} Environment | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
cache: 'yarn' | |
- name: 'Install packages, build and test' | |
shell: bash | |
run: | | |
yarn | |
yarn build | |
yarn test | |
deploy-to-azure: | |
if: (github.ref == 'refs/heads/dev') || (github.ref == 'refs/heads/master') || (github.event.inputs.environment != null) | |
name: Build app and deploy to Azure | |
runs-on: ubuntu-latest | |
environment: ${{ needs.setupEnv.outputs.githubEnvironment }} | |
concurrency: ${{ needs.setupEnv.outputs.name }} | |
needs: | |
- setupEnv | |
- build-and-test | |
env: | |
environment: ${{ needs.setupEnv.outputs.environment }} | |
steps: | |
- name: 'Checkout GitHub Action' | |
uses: actions/checkout@v4 | |
- name: Setup Node ${{ env.NODE_VERSION }} Environment | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
cache: 'yarn' | |
- name: 'Install packages and build' | |
shell: bash | |
run: | | |
yarn | |
yarn build | |
- name: Azure Login | |
timeout-minutes: 5 | |
uses: azure/login@v1 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
- name: Create infrastructure | |
run: infra/azure/apps/api/scripts/create-funcapp.sh | |
env: | |
DB_PASSWORD: ${{ secrets.DB_PASSWORD }} | |
- name: Install zip | |
uses: montudor/action-zip@v1 | |
- name: 'Deploy to Azure Functions' | |
run: infra/azure/apps/api/scripts/deploy-funcapp.sh | |
- name: Azure Logout | |
if: ${{ always() }} | |
run: | | |
az logout | |
az cache purge | |
az account clear | |