name: Deploy Node.js app to Azure Functions
- main # Change to any branch to appropriate your project.
AZURE_FUNCTIONS_APP_PACKAGE_PATH: '.' # Set this to the path of your function app project, defaults to the repository root.
NODE_VERSION: 12.x # Set Node.js version to use.
# Find more virtual environments
# https://www.dotnetthailand.com/programming-cookbook/github-actions/github-actions-fundamentals#findmorevirtualenvironments
# You can use default run to set a default working directory
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_iddefaultsrun
working-directory: ${{ env.AZURE_FUNCTIONS_APP_PACKAGE_PATH }}
- name: Checkout the latest source code from ${{ github.ref }} commit
uses: actions/checkout@v2 # https://github.com/actions/checkout
- name: Install Azure Functions Core Tools
# Yarn's already installed on a virtual environment https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu1804-README.md#package-management
# Install the Microsoft package repository GPG key, to validate package integrity.
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
# Set up the APT source list before doing an APT update.
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-$(lsb_release -cs)-prod $(lsb_release -cs) main" > \
/etc/apt/sources.list.d/dotnetdev.list'
# Install the Core Tools package.
sudo apt-get install azure-functions-core-tools-3
- name: Use Node.js version ${{ env.NODE_VERSION }}
uses: actions/setup-node@v2 # https://github.com/actions/setup-node
node-version: ${{ env.NODE_VERSION }}
- name: Build a Node.js project with Yarn
# Yarn's already installed on a virtual environment https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu1804-README.md#package-management
yarn run build:production
- name: Deploy Node.js app to Azure Functions
uses: Azure/functions-action@v1 # https://github.com/Azure/functions-action
app-name: ${{ secrets.AZURE_FUNCTIONS_APP_NAME }}
package: ${{ env.AZURE_FUNCTIONS_APP_PACKAGE_PATH }}
publish-profile: ${{ secrets.AZURE_FUNCTIONS_APP_PUBLISH_PROFILE }}