chore: Update matrix-config.yml to include database options for MySQL… #1
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: Build and Deploy Node App to Azure | |
on: | |
push: | |
branches: [ "main" ] | |
workflow_dispatch: | |
env: | |
NODE_APP_PATH: './node-app' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout the repository | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# Set up Node.js environment | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ secrets.NODE_VERSION }} | |
# Cache Node.js dependencies | |
- name: Cache Node.js dependencies | |
id: cache-node-modules | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ secrets.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node-${{ secrets.NODE_VERSION }}- | |
# Install dependencies | |
- name: Install dependencies | |
run: | | |
npm ci | |
npm config set cache ~/.npm --global | |
working-directory: ${{ env.NODE_APP_PATH }} | |
# Run tests | |
- name: Run tests | |
run: npm test | |
working-directory: ${{ env.NODE_APP_PATH }} | |
# Build the app | |
- name: Build app | |
run: npm run build | |
working-directory: ${{ env.NODE_APP_PATH }} | |
# Upload build artifacts | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: node-app-build | |
path: ${{ env.NODE_APP_PATH }}/dist | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
environment: | |
name: 'Production' | |
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} | |
steps: | |
# Download build artifacts from the build job | |
- name: Download artifact from build job | |
uses: actions/download-artifact@v3 | |
with: | |
name: node-app-build | |
# Deploy to Azure WebApp | |
- name: 'Deploy to Azure WebApp' | |
id: deploy-to-webapp | |
uses: azure/webapps-deploy@v2 | |
with: | |
app-name: ${{ secrets.AZURE_WEBAPP_NAME }} | |
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} | |
package: ${{ env.NODE_APP_PATH }} | |
# Print GitHub context | |
- name: Print GitHub context | |
run: | | |
echo "Repository: ${{ github.repository }}" | |
echo "Ref: ${{ github.ref }}" | |
echo "SHA: ${{ github.sha }}" | |
echo "Actor: ${{ github.actor }}" | |
echo "Event Name: ${{ github.event_name }}" | |
echo "Workflow: ${{ github.workflow }}" | |
echo "Run ID: ${{ github.run_id }}" | |
echo "Run Number: ${{ github.run_number }}" |