我在一个名为 terraform-do-database
的 repo 中有这个工作流程,我正在尝试使用来自公共(public) repo foo/git-workflows/.github/的可重用工作流程workflows/tag_validation.yaml@master
name: Tag Validation
on:
pull_request:
branches: [master]
push:
branches:
- '*' # matches every branch that doesn't contain a '/'
- '*/*' # matches every branch containing a single '/'
- '**' # matches every branch
- '!master' # excludes master
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
tag_check:
uses: foo/git-workflows/.github/workflows/tag_validation.yaml@master
这是来自公共(public) git-workflows
存储库的可重用工作流文件,其中包含应在其上运行的脚本。发生的事情是工作流试图在 repo terraform-do-database
name: Tag Validation
on:
pull_request:
branches: [master]
workflow_call:
jobs:
tag_check:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
# Runs a single command using the runners shell
- name: Verify the tag value
run: ./scripts/tag_verify.sh
所以问题是:如何让工作流使用存储在 git-worflows
存储库中的脚本而不是 terraform-do-database?
我想要一个可以调用工作流和脚本的存储库,我不想在我的所有存储库中复制所有内容。
最佳答案
我发现,如果我将脚本包装成复合 Action 。我可以使用 GitHub 上下文 github.action_path
来定位脚本。
示例:
运行:${{ github.action_path }}/scripts/foo.sh
关于github - 如何在可重用的 github 工作流程中执行远程脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72133102/