Azure / actions-workflow-samples

Help developers to easily get started with GitHub Action workflows to deploy to Azure
https://github.com/Azure/actions
MIT License
447 stars 624 forks source link

usr/local/tomcat/webapps/ROOT/WEB-INF folder remains empty from GITHub Actions Java Web App deploy #137

Open BasujitaBhattacharya opened 1 year ago

BasujitaBhattacharya commented 1 year ago

I am Deploying a Simple Java Web App in Azure App Service using GitHub Actions workflow file. App Service is running on Java11/Tomcat 9.0 stack.

Java Code > https://github.com/BasujitaBhattacharya/JavaWebApp.

The artefacts generated after the mvn clean install has the classes and lib folder generated inside the snapshot war. However, after the deploy action when my webapp failed to function as expected, I connected to the container via ssh and found that WEB-INF folder is empty.

The folder structure should be WEB-INF\classes\com\valeykey\frontend. The class files must be inside this directory structure.

Any insights will be really helpful, thanks in advance.

Below is my GH Actions workflow file >

name: Build and deploy WAR app to Azure Web App - JavaWebAppfromPortal

name: Build and deploy JAR app to Azure Web App

env: JAVA_VERSION: '11' # set this to the Java version to use DISTRIBUTION: microsoft # set this to the Java distribution AZURE_WEBAPP_PACKAGE_PATH : ./AppService/JavaWebApp

on: push: branches: [ "main" ] workflow_dispatch:

permissions: contents: read

jobs: build: runs-on: ubuntu-latest

steps:
  - uses: actions/checkout@v3

  - name: Set up Java version
    uses: actions/setup-java@v3.0.0
    with:
      java-version: ${{ env.JAVA_VERSION }}
      distribution: ${{ env.DISTRIBUTION }}
      cache: 'maven'

  - name: Build with Maven
    run: mvn clean install
    working-directory: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}

  - name: Upload artifact for deployment job
    uses: actions/upload-artifact@v3
    with:
      name: java-app
      path: '${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/target/*.war'

deploy: permissions: contents: none runs-on: ubuntu-latest needs: build environment: name: 'Development' url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

steps:
  - name: Download artifact from build job
    uses: actions/download-artifact@v3
    with:
      name: java-app
  - run: ls

  - name: Deploy to Azure Web App
    id: deploy-to-webapp
    uses: azure/webapps-deploy@v2
    with:
      app-name: ${{ secrets.APP_SERVICE_NAME }}
      publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
      package: '*.war'