This GitHub Actions workflow automates the process of building and deploying a Node.js application to an Azure Web App whenever a commit is pushed to the master branch.
- An existing Azure App Service web app. If you haven't created one, follow the guide here.
- The repository should contain the Node.js application that you want to deploy.
-
Download the Publish Profile:
From the Overview page of your Web App in the Azure Portal, download the Publish Profile.
More details can be found here. -
Add Publish Profile to GitHub Secrets:
In your GitHub repository, create a new secret namedAZURE_WEBAPP_PUBLISH_PROFILE
. Paste the contents of the Publish Profile you downloaded in the previous step as the value.
Instructions can be found here. -
Configure Environment Variables:
In the workflow file:- Set
AZURE_WEBAPP_NAME
to your Azure Web App's name. - Optionally, you can modify the
AZURE_WEBAPP_PACKAGE_PATH
if your project is not in the repository root. - Optionally, you can set
NODE_VERSION
to the desired version. By default, it's set to version16.x
.
- Set
-
Trigger:
The workflow is triggered on a push to themaster
branch or can be dispatched manually. -
Build Job:
- Checks out the repository.
- Sets up the desired Node.js version.
- Installs npm dependencies, builds the application, and runs tests (if they exist).
- Uploads the built application as an artifact for the deployment job.
-
Deploy Job:
- Downloads the built application artifact.
- Deploys the application to the Azure Web App using the provided Publish Profile and app name.