获取部署 url 以传递到下一步 - 具有 Github 操作的 Azure 静态 Web 应用
Get deployment url to be passed to next step - Azure Static Web apps with Github actions
我正在使用带有 Github 操作的 Azure 静态 Web 应用程序,我需要将部署 URL 传递到下一步。
知道如何获得它吗?步骤 获取部署 URL 失败,环境为空错误。这是我的 yml 文件。
name: Azure Static Web Apps CI/CD
on:
push:
branches:
- dev
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- dev
jobs:
build_and_deploy_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_HAPPY_RIVER_01F5A930F }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: "upload"
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: "/" # App source code path
api_location: "" # Api source code path - optional
output_location: "build" # Built app content directory - optional
env:
VITE_AG_GRID_LICENSE_KEY: ${{secrets.VITE_AG_GRID_LICENSE_KEY}}
VITE_API_SCOPE: ${{secrets.VITE_API_SCOPE}}
VITE_CLIENT_ID: ${{secrets.VITE_CLIENT_ID}}
VITE_SOURCE_LOADER_BASE_URL: ${{secrets.VITE_SOURCE_LOADER_BASE_URL_DEV}}
VITE_TENANT_ID: ${{secrets.VITE_TENANT_ID}}
- name: Get deployment URL
id: deployment
uses: dorshinar/get-deployment-url@master
timeout-minutes: 5
with:
token: ${{ secrets.GITHUB_TOKEN }}
- run: echo ${{ steps.deployment.outputs.deployment }}
close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_HAPPY_RIVER_01F5A930F }}
action: "close"
您应该能够从 Azure/static-web-apps-deploy
:
中获取 URL 作为输出参数
...
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
...
- name: Print Deployment URL
run: echo ${{ steps.builddeploy.outputs.static_web_app_url }}
这是一个 link 定义的动作 yml。
在我的例子中,它给出了一个空字符串,如下所示。
Environment URL '' is not a valid http(s) URL, so it will not be shown as a link in the workflow graph.
我通过重新启动 Azure AppService 解决了这个问题。
一定要检查失败的构建步骤,因为这个错误也可能是错误的指示。
我正在使用带有 Github 操作的 Azure 静态 Web 应用程序,我需要将部署 URL 传递到下一步。
知道如何获得它吗?步骤 获取部署 URL 失败,环境为空错误。这是我的 yml 文件。
name: Azure Static Web Apps CI/CD
on:
push:
branches:
- dev
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- dev
jobs:
build_and_deploy_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_HAPPY_RIVER_01F5A930F }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: "upload"
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: "/" # App source code path
api_location: "" # Api source code path - optional
output_location: "build" # Built app content directory - optional
env:
VITE_AG_GRID_LICENSE_KEY: ${{secrets.VITE_AG_GRID_LICENSE_KEY}}
VITE_API_SCOPE: ${{secrets.VITE_API_SCOPE}}
VITE_CLIENT_ID: ${{secrets.VITE_CLIENT_ID}}
VITE_SOURCE_LOADER_BASE_URL: ${{secrets.VITE_SOURCE_LOADER_BASE_URL_DEV}}
VITE_TENANT_ID: ${{secrets.VITE_TENANT_ID}}
- name: Get deployment URL
id: deployment
uses: dorshinar/get-deployment-url@master
timeout-minutes: 5
with:
token: ${{ secrets.GITHUB_TOKEN }}
- run: echo ${{ steps.deployment.outputs.deployment }}
close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_HAPPY_RIVER_01F5A930F }}
action: "close"
您应该能够从 Azure/static-web-apps-deploy
:
...
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
...
- name: Print Deployment URL
run: echo ${{ steps.builddeploy.outputs.static_web_app_url }}
这是一个 link 定义的动作 yml。
在我的例子中,它给出了一个空字符串,如下所示。
Environment URL '' is not a valid http(s) URL, so it will not be shown as a link in the workflow graph.
我通过重新启动 Azure AppService 解决了这个问题。
一定要检查失败的构建步骤,因为这个错误也可能是错误的指示。