0

I am trying to deploy to Azure Webapp using GitHub Actions. The install of the private repo goes correctly, but step azure/webapps-deploy goes wrong, since it tries to install the private repo again, but does not have access.

Any idea how I can make this work?

My YAML:

name: Deploy staging
on:
  push:
    branches:
      - development

env:
  AZURE_WEBAPP_NAME: webapp
  WORKING_DIRECTORY: '.'
  PYTHON_VERSION: '3.10'
  STARTUP_COMMAND: ''

jobs:
 build-and-deploy:
  runs-on: ubuntu-latest
  steps:
  - uses: actions/checkout@master

  - name: Setup Python
    uses: actions/setup-python@v4
    with:
     python-version: ${{ env.PYTHON_VERSION }}

  - name: python install
    working-directory: ${{ env.WORKING_DIRECTORY }}
    run: |
      pushd './${{ env.WORKING_DIRECTORY }}'
      python -m pip install --upgrade pip
      git config --global url."https://${{ secrets.ACCESS_TOKEN }}@github".insteadOf https://github
      pip install -r requirements.txt --target=".python_packages/lib/site-packages"
      popd

  - name: Setup Node 18.x
    uses: actions/setup-node@v3
    with:
      node-version: 18
  - name: Install NPM
    run: |
      npm install
      npx tailwindcss -i ./src/static/input.css -o ./src/static/dist/output.css

  - uses: azure/login@v1
    with:
     creds: ${{ secrets.AZURE_SERVICE_PRINCIPAL_WEBAPP }}
  - uses: azure/appservice-settings@v1
    with:
     app-name: ${{ env.AZURE_WEBAPP_NAME }}
     mask-inputs: false
     general-settings-json: '{"linuxFxVersion": "PYTHON|${{ env.PYTHON_VERSION }}"}' #'General configuration settings as Key Value pairs'
  # deploy web app
  - uses: azure/webapps-deploy@v2
    with:
     app-name: ${{ env.AZURE_WEBAPP_NAME }}
     slot-name: 'dev'
     package: ${{ env.WORKING_DIRECTORY }}
     startup-command: ${{ env.STARTUP_COMMAND }}
  # Azure logout
  - name: logout
    run: |
     az logout

enter image description here

Error log:

Package deployment using ZIP Deploy initiated.
Updating submodules.
Preparing deployment for commit id '3bf7d247-a'.
PreDeployment: context.CleanOutputPath False
PreDeployment: context.OutputPath /home/site/wwwroot
Repository path is /tmp/zipdeploy/extracted
Running oryx build...
Command: oryx build /tmp/zipdeploy/extracted -o /home/site/wwwroot --platform python --platform-version 3.10 -p virtualenv_name=antenv --log-file /tmp/build-debug.log  -i /tmp/8db894f894ef4e2 --compress-destination-dir | tee /tmp/oryx-build.log
Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx
You can report issues at https://github.com/Microsoft/Oryx/issues

Oryx Version: 0.2.20230508.1, Commit: 7fe2bf39b357dd68572b438a85ca50b5ecfb4592, ReleaseTagName: 20230508.1

Build Operation ID: 7b6faa414a4450ba
Repository Commit : 3bf7d247-a0b4-4afd-9325-d2e7b5c8eaec
OS Type           : bullseye
Image Type        : githubactions

Detecting platforms...
Detected following platforms:
  nodejs: 16.20.1
  python: 3.10.8

Using intermediate directory '/tmp/8db894f894ef4e2'.

Copying files to the intermediate directory...
Done in 3 sec(s).

Source directory     : /tmp/8db894f894ef4e2
Destination directory: /home/site/wwwroot

Python Version: /tmp/oryx/platforms/python/3.10.8/bin/python3.10
Creating directory for command manifest file if it does not exist
Removing existing manifest file
Python Virtual Environment: antenv
Creating virtual environment...
Activating virtual environment...
Running pip install...
[18:31:46+0000] Collecting app_base_templates
[18:31:46+0000]   Cloning https://github.com/org/app_base_templates.git to /tmp/pip-install-6ji8be4t/app_96b6a45facdb46e49333e02b79e241e9
  Running command git clone --filter=blob:none --quiet https://github.com/org/app.git /tmp/pip-install-6ji8be4t/app96b6a45facdb46e49333e02b79e241e9
  fatal: could not read Username for 'https://github.com': No such device or address
  error: subprocess-exited-with-error
  
  × git clone --filter=blob:none --quiet https://github.com/org/app.git /tmp/pip-install-6ji8be4t/app_96b6a45facdb46e49333e02b79e241e9 did not run successfully.
  │ exit code: 128
  ╰─> See above for output.
Zal
  • 935
  • 1
  • 7
  • 17

1 Answers1

0

I tried Deploying a sample Private Django web app repository with github actions and it was successful, Refer below:-

I connected to my private github repository from My Azure Web app > Deployment > Deployment Center like below:-

In order for the github workflow deployment to run successfully, Make sure you have the below settings added in the Configuration:-

WEBSITE_WEBDEPLOY_USE_SCM true
SCM_DO_BUILD_DURING_DEPLOYMENT 1

Enable the Basic Auth Publishing Credentials to On:-

enter image description here

In addition to this make sure you have added the domain url of Azure web app in your Python’s app settings.py like below:-

ALLOWED_HOSTS  = ['https://valleywebapp0.azurewebsites.net/']

enter image description here

Logged in and connected to my Private Github Repository like below and saved the settings to run the workflow:-

enter image description here

My github workflow script:-

name: Build and deploy Python app to Azure Web App - valleywebapp0

on:
  push:
    branches:
      - master
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Set up Python version
        uses: actions/setup-python@v1
        with:
          python-version: '3.9'

      - name: Create and start virtual environment
        run: |
          python -m venv venv
          source venv/bin/activate
      
      - name: Install dependencies
        run: pip install -r requirements.txt
        
      
      - name: Upload artifact for deployment jobs
        uses: actions/upload-artifact@v2
        with:
          name: python-app
          path: |
            . 
            !venv/
  deploy:
    runs-on: ubuntu-latest
    needs: build
    environment:
      name: 'Production'
      url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

    steps:
      - name: Download artifact from build job
        uses: actions/download-artifact@v2
        with:
          name: python-app
          path: .
          
      - name: 'Deploy to Azure Web App'
        uses: azure/webapps-deploy@v2
        id: deploy-to-webapp
        with:
          app-name: 'valleywebapp0'
          slot-name: 'Production'
          publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_FBE0A8A87E804D00802E7E91678FC5E5 }}

enter image description here

enter image description here

References:-

github - unable to deploy to azure web app services - Stack Overflow

azure - deployment Failed with Error: Package deployment using ZIP Deploy failed. Refer logs for more details - Stack Overflow

Naveen Sharma
  • 349
  • 2
  • 4