我想在使用webapps-deploy
部署应用程序时将当前GitHub提交SHA设置为环境变量:https://github.com/Azure/webapps-deploy
我该如何实现这一点?
我现在的yaml看起来像这样:
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions
# More info on Python, GitHub Actions, and Azure App Service: https://aka.ms/python-webapps-actions
name: My App Deployment Pipeline
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Set up Python version
uses: actions/setup-python@v3
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
python -m playwright install
- name: Build Project
run: |
cd frontend
npm ci
npm run build
- name: Upload artifact for deployment jobs
uses: actions/upload-artifact@v2
with:
name: python-app
path: |
.
!venv/
!frontend/node_modules/
retention-days: 5
deploy-staging:
name: Deploy to staging
runs-on: ubuntu-latest
needs: build
environment:
name: 'stage'
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: 'my-app-name'
slot-name: 'Production'
publish-profile: ${{ secrets.publishprofile }}
deploy-production:
name: Deploy to production
runs-on: ubuntu-latest
needs: [build, deploy-staging]
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: 'my-app-name'
slot-name: 'Production'
publish-profile: ${{ secrets.publishprofile }}
字符串
1条答案
按热度按时间whhtz7ly1#
我尝试了下面的代码来设置Commit SHA环境变量,它在Python Azure Web应用程序github操作工作流中成功工作。
我的github操作工作流程:-
完整的工作流代码可在此处参考。
字符串
输出:-
x1c 0d1x的数据