Skip to content

Latest commit

 

History

History
260 lines (205 loc) · 7.79 KB

deploy-github-actions-publish-profile.md

File metadata and controls

260 lines (205 loc) · 7.79 KB
authorms.authorms.topicms.date
cephalin
cephalin
include
01/16/2025

The publish-profile input should reference the AZURE_WEBAPP_PUBLISH_PROFILE GitHub secret that you created earlier.

name: .NET Core CIon: [push]env: AZURE_WEBAPP_NAME: my-app-name # Set this to your application's nameAZURE_WEBAPP_PACKAGE_PATH: '.'# Set this to the path to your web app project, defaults to the repository rootDOTNET_VERSION: '6.0.x'# Set this to the dot net version to usejobs: build: runs-on: ubuntu-lateststeps: # Check out the repo - uses: actions/checkout@main# Setup .NET Core SDK - name: Setup .NET Coreuses: actions/setup-dotnet@v3with: dotnet-version: ${{ env.DOTNET_VERSION }} # Run dotnet build and publish - name: dotnet build and publishrun: | dotnet restore dotnet build --configuration Release dotnet publish -c Release --property:PublishDir='${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/myapp' # Deploy to Azure Web apps - name: 'Run Azure webapp deploy action using publish profile credentials'uses: azure/webapps-deploy@v3with: app-name: ${{ env.AZURE_WEBAPP_NAME }} # Replace with your app namepublish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} # Define secret variable in repository settings as per action documentationpackage: '${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/myapp'

Build and deploy an ASP.NET model-view-controller (MVC) app that uses NuGet and publish-profile for authentication.

name: Deploy ASP.NET MVC App deploy to Azure Web Appon: [push]env: AZURE_WEBAPP_NAME: my-app # Set this to your application's nameAZURE_WEBAPP_PACKAGE_PATH: '.'# Set this to the path to your web app project, defaults to the repository rootNUGET_VERSION: '5.3.x'# Set this to the dot net version to usejobs: build-and-deploy: runs-on: windows-lateststeps: - uses: actions/checkout@main  - name: Install Nugetuses: nuget/setup-nuget@v1with: nuget-version: ${{ env.NUGET_VERSION}} - name: NuGet to restore dependencies as well as project-specific tools that are specified in the project filerun: nuget restore - name: Add msbuild to PATHuses: microsoft/setup-msbuild@v1.0.2 - name: Run MSBuildrun: msbuild .\SampleWebApplication.sln - name: 'Run Azure webapp deploy action using publish profile credentials'uses: azure/webapps-deploy@v3with: app-name: ${{ env.AZURE_WEBAPP_NAME }} # Replace with your app namepublish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} # Define secret variable in repository settings as per action documentationpackage: '${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/SampleWebApplication/'

Build and deploy a Java Spring Boot app to Azure by using an Azure publish profile. The publish-profile input references the AZURE_WEBAPP_PUBLISH_PROFILE secret that you created earlier.

name: Java CI with Mavenon: [push]jobs: build: runs-on: ubuntu-lateststeps: - uses: actions/checkout@v4 - name: Set up JDK 1.8uses: actions/setup-java@v3with: java-version: 1.8 - name: Build with Mavenrun: mvn -B package --file pom.xmlworking-directory: my-app-path - name: Azure WebAppuses: Azure/webapps-deploy@v3with: app-name: my-app-namepublish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}package: my/target/*.jar

To deploy a war instead of a jar, change the package value.

 - name: Azure WebAppuses: Azure/webapps-deploy@v3with: app-name: my-app-namepublish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}package: my/target/*.war

Build and deploy a Tomcat app to Azure by using an Azure publish profile. The publish-profile input references the AZURE_WEBAPP_PUBLISH_PROFILE secret that you created earlier.

name: Build and deploy WAR app to Azure Web App using publish profileenv: JAVA_VERSION: '11'# Set this to the Java version to useDISTRIBUTION: microsoft # Set this to the Java distributionAZURE_WEBAPP_NAME: sampleapp # Set this to the name of your web appon: [push]permissions: id-token: writecontents: readjobs: build: runs-on: ubuntu-lateststeps: - uses: actions/checkout@v4 - name: Set up Java versionuses: actions/setup-java@v3.0.0with: java-version: ${{ env.JAVA_VERSION }}distribution: ${{ env.DISTRIBUTION }}cache: 'maven' - name: Build with Mavenrun: mvn clean install - name: Deploy to Azure Web Appid: deploy-to-webappuses: azure/webapps-deploy@v3with: app-name: ${{ env.AZURE_WEBAPP_NAME }}publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}package: '*.war'

Here's a full example that uses multiple jobs for build and deploy.

Build and deploy a Node.js app to Azure by using the app's publish profile. The publish-profile input references the AZURE_WEBAPP_PUBLISH_PROFILE secret that you created earlier.

# File: .github/workflows/workflow.ymlname: JavaScript CIon: [push]env: AZURE_WEBAPP_NAME: my-app-name # Set this to your application's nameAZURE_WEBAPP_PACKAGE_PATH: 'my-app-path'# Set this to the path to your web app project, defaults to the repository rootNODE_VERSION: '18.x'# Set this to the node version to usejobs: build-and-deploy: name: Build and Deployruns-on: ubuntu-lateststeps: - uses: actions/checkout@main - name: Use Node.js ${{ env.NODE_VERSION }}uses: actions/setup-node@v4with: node-version: ${{ env.NODE_VERSION }} - name: npm install, build, and testrun: | # Build and test the project, then # deploy to Azure Web App. npm install npm run build --if-present npm run test --if-presentworking-directory: my-app-path - name: 'Deploy to Azure WebApp'uses: azure/webapps-deploy@v3with: app-name: ${{ env.AZURE_WEBAPP_NAME }}publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}

Build and deploy a Python app to Azure by using the app's publish profile. Note how the publish-profile input references the AZURE_WEBAPP_PUBLISH_PROFILE secret that you created earlier.

name: Python CIon: [push]env: AZURE_WEBAPP_NAME: my-web-app # Set this to your application's nameAZURE_WEBAPP_PACKAGE_PATH: '.'# Set this to the path to your web app project, defaults to the repository rootjobs: build: runs-on: ubuntu-lateststeps: - uses: actions/checkout@v4 - name: Set up Python 3.xuses: actions/setup-python@v4with: python-version: 3.x - name: Install dependenciesrun: | python -m pip install --upgrade pip pip install -r requirements.txt - name: Building web appuses: azure/appservice-build@v2 - name: Deploy web App using GH Action azure/webapps-deployuses: azure/webapps-deploy@v3with: app-name: ${{ env.AZURE_WEBAPP_NAME }}publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}

close