【问题标题】:Static Web App Deploy with Azure using specific Node version使用特定节点版本与 Azure 一起部署静态 Web 应用程序
【发布时间】:2020-12-27 19:24:25
【问题描述】:

我正在尝试使用带有 Github Actions 的 Azure 服务部署静态 Web 应用程序。

问题是,我需要使用 NodeJS 运行脚本。我正在使用在 Node v14 中运行良好的 ESM 模块。问题是,在构建任务期间,Azure(或 github)使用不支持 ESM 模块的 v12.8(我猜是 LTS)。

name: Azure Static Web Apps CI/CD

on:
  push:
    branches:
      - master
  pull_request:
    types: [opened, synchronize, reopened, closed]
    branches:
      - master

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: Build And Deploy
        id: builddeploy
        uses: Azure/static-web-apps-deploy@v0.0.1-preview
        with:
          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_LEMON_GLACIER_0C510BD03 }}
          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 you 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" # Api source code path - optional
          app_artifact_location: "public" # Built app content directory - optional
          ###### End of Repository/Build Configurations ######

  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@v0.0.1-preview
        with:
          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_LEMON_GLACIER_0C510BD03 }}
          action: "close"

我试图使用此步骤指定节点版本:

- name: Setup Node 14.x
  uses: actions/setup-node@v1
    with:
      node-version: '14.x'

不过,构建过程使用 12.8。

我做错了什么,是否可以在我的情况下使用特定版本?

【问题讨论】:

  • 请将日志添加到您的问题中,说明它使用的是 12.8。根据文档,该操作使用 Microsoft 的构建系统 Oryx,您可能必须相应地进行配置。
  • @riQQ 我找到了文档,它说只支持 LTS 版本,即 12.8。 v14 将在 10 月成为 LTS。我会结束这个问题。感谢您的宝贵时间!

标签: node.js azure github-actions


【解决方案1】:

文档说受支持的 Node 版本仅与 LTS 一样高。目前12.8。您现在无法对 v14.x 使用 Azure/static-web-apps-deploy@v0.0.1-preview 操作。

我通过使用 github-actions 并将构建推送到 azure 存储解决了这个问题。

【讨论】:

    猜你喜欢
    • 2020-05-03
    • 1970-01-01
    • 1970-01-01
    • 2016-04-22
    • 2017-01-13
    • 1970-01-01
    • 2021-05-14
    • 2013-10-29
    • 2017-03-04
    相关资源
    最近更新 更多