如何在可重用 github 工作流程中执行远程脚本
How to execute a a remote script in a reusable github workflow
我在一个名为 terraform-do-database
的存储库中有这个工作流,我正在尝试使用来自 public 存储库的可重用工作流 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?
我想要一个可以调用工作流和脚本的存储库,我不想在我的所有存储库中复制所有内容。
根据这个 thread on github-community 脚本需要单独 downloaded/checked 出来。
您发布的“可重用”工作流在这个意义上是不可重用的,因为由于它不下载脚本,工作流只能 运行 在它自己的存储库(或已经有脚本的存储库)中.
我添加了一些命令来手动下载脚本并执行它,从而解决了这个问题。
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: Check current directory
run: pwd
- name: Download the script
run: curl -o $PWD/tag_verify.sh https://raw.githubusercontent.com/foo/git-workflows/master/scripts/tag_verify.sh
- name: Give script permissions
run: chmod +x $PWD/tag_verify.sh
- name: Execute script
run: $PWD/tag_verify.sh
我在一个名为 terraform-do-database
的存储库中有这个工作流,我正在尝试使用来自 public 存储库的可重用工作流 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?
我想要一个可以调用工作流和脚本的存储库,我不想在我的所有存储库中复制所有内容。
根据这个 thread on github-community 脚本需要单独 downloaded/checked 出来。
您发布的“可重用”工作流在这个意义上是不可重用的,因为由于它不下载脚本,工作流只能 运行 在它自己的存储库(或已经有脚本的存储库)中.
我添加了一些命令来手动下载脚本并执行它,从而解决了这个问题。
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: Check current directory
run: pwd
- name: Download the script
run: curl -o $PWD/tag_verify.sh https://raw.githubusercontent.com/foo/git-workflows/master/scripts/tag_verify.sh
- name: Give script permissions
run: chmod +x $PWD/tag_verify.sh
- name: Execute script
run: $PWD/tag_verify.sh