github-actions - 如何将仅静态文件的模式与所有修改的更改相匹配,以在 github 操作中运行 zappa 命令?

标签 github-actions

在yaml文件中,如何运行zappa命令manage devcollectstatic --noinputif条件以仅匹配静态文件模式?###

name: CI/CD

on: push

jobs:
 deploy:
  runs-on: ubuntu-latest
  steps:
    - name: Set up Python 3.10
      uses: actions/setup-python@v3
      with:
        python-version: '3.10'
    - name: Run step only when any of the static files are changed, modified, or added.
     if: (condtion--??)
     run: |
       zappa manage dev collectstatic --noinput

我正在尝试使用 zappa 和 aws lambda 以及 GitHub 操作来部署 Django 项目。

我只想检查更新或添加的静态文件,这些文件将使用运行命令 zappa Manage devcollectstatic --noinput 从开发合并到主分支yaml 文件。

如何为与所有静态文件匹配的模式设置条件?

最佳答案

您可以尝试添加 GitHub 操作“tj-actions/changed-files ”,它检索相对于目标分支的所有已更改文件和目录或返回从项目根目录返回相对路径的最后一个远程提交。

您可以在GitHub Action to run mypy on changed files only中的“Carlos Villavicencio”中看到示例.

就您而言:

name: CI/CD

on: push

jobs:
 deploy:
  runs-on: ubuntu-latest
  steps:
    - name: Set up Python 3.10
      uses: actions/setup-python@v3
      with:
        python-version: '3.10'
    - name: Get Python changed files
      id: changed-py-files
      uses: tj-actions/changed-files@v23
      with:
        files: |
          *.py
          **/*.py
    - name: Run step only when any of the static files are changed, modified, or added.
     if: steps.changed-py-files.outputs.any_changed == 'true'
     run: |
       zappa manage dev collectstatic --noinput

将模式 *.py**/*.py 替换为您要监控的实际静态文件模式。

关于github-actions - 如何将仅静态文件的模式与所有修改的更改相匹配,以在 github 操作中运行 zappa 命令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75565140/

相关文章:

尽管所有需求均已成功,但 GitHub Actions 作业被跳过

github-actions - 如何仅在特定推送选项上触发 Github 操作?

github - 如何使用github Action 在commit上创建注释?

docker - 我可以在 GitHub Actions 工作流程中引用 Dockerfile 而不是图像吗?

Github 操作 : Required status check doesn't run due to files in paths not changed

kubectl - 如何将 github secret 变量通过管道传输到文件中

docker - 使用 docker/build-push-action 在 GitHub Actions 中本地构建 docker 镜像

node.js - Github Action err : bash: line 3: npm: command not found

azure - 将自定义镜像推送到 Azure ACR 失败 "Use of closed network connection "

node.js - 尝试将 Vue 应用程序部署到 Azure 应用程序服务,导致错误 : Cannot find module '../package.json'