在我們的 github 存盤庫中,我們有一個在環境中呼叫可重用作業流的 github 操作。
name: Pull Request Merged
concurrency:
group: ${{ github.ref }}
on:
pull_request:
types: [closed]
jobs:
deploy_to_stage:
if: |
github.event.pull_request.merged == true &&
contains(github.event.pull_request.labels.*.name, 'Stage')
name: Deploy to Stage
uses: ./.github/workflows/deploy.yml
with:
environment: Stage
secrets: inherit
可復用的作業流程大致如下:
name: deploy
on:
workflow_call:
secrets:
AWS_ACCESS_KEY_ID:
required: true
AWS_SECRET_ACCESS_KEY:
required: true
jobs:
deployment:
runs-on: ubuntu-latest
steps:
[...]
如何在可重用作業流程的某個步驟中訪問環境名稱(此處為“Stage”)的值?
uj5u.com熱心網友回復:
無法從作業流背景關系中獲取此值。
environment解決方法是在接收值的可重用作業流中添加輸入:
name: deploy
on:
workflow_call:
inputs:
environment:
required: true
secrets:
AWS_ACCESS_KEY_ID:
required: true
AWS_SECRET_ACCESS_KEY:
required: true
然后,您可以通過使用${{ inputs.environment }}.
uj5u.com熱心網友回復:
您可以使用環境機密在該部署環境中存盤階段名稱,然后在您的腳本(例如bash 腳本)中訪問環境變數或作為操作的一個組成部分${{ env.DAY_OF_WEEK == 'Monday' }}(ref)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/537652.html
上一篇:Angular在本地構建,而不是在Github上。獲取npm錯誤!-Oryx未能構建解決方案
下一篇:從遠程撤消共享合并功能分支
