Azure Webapp使用Github Actions部署并安装私有存储库

gywdnpxw  于 2023-08-07  发布在  Git
关注(0)|答案(1)|浏览(152)

我正在尝试使用GitHub操作部署到Azure Webapp。私有存储库的安装正常进行,但步骤azure/webapps-deploy出错,因为它试图再次安装私有存储库,但没有访问权限。
你知道我该怎么做吗?
我的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

字符串


的数据
错误日志:

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.

jslywgbw

jslywgbw1#

我尝试使用github操作部署一个示例私有Django Web应用程序存储库,并且成功,参考下面:
我从我的 *Azure Web应用>部署>部署中心 * 连接到我的私有github存储库,如下所示:-
为了让github工作流部署成功运行,请确保在配置中添加了以下设置:

WEBSITE_WEBDEPLOY_USE_SCM true
SCM_DO_BUILD_DURING_DEPLOYMENT 1

字符串
启用 * 基本身份验证发布凭据为开 *:-
x1c 0d1x的数据
除此之外,请确保您已在Python的应用程序settings.py中添加了Azure Web应用程序的域URL,如下所示:

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


  • 登录并连接到我的私人Github仓库,如下所示,并保存了运行工作流的设置:-*


我的github工作流脚本:-

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 }}



x1c4d 1x的

参考文献:-

github - unable to deploy to azure web app services - Stack Overflow
Azure -部署失败,错误:使用ZIP Deploy部署包失败。有关更多详细信息,请参阅日志-堆栈溢出

相关问题