簡體   English   中英

Github Actions 矩陣問題

[英]Github Actions matrix questions

我只希望它在 Matrix 中針對 INT、STG 環境運行,並且對於每個環境,我需要更長的名稱(集成、暫存)。

這件事在 github 操作中可能嗎? 我錯過了 sytanx 中的某些內容嗎? 我試着四處尋找它並找不到它。。

Test:
 name: Deploy Test
 runs-on: ${{matrix.env}}
 strategy:
 matrix:
 env: [int, stg]
 needs: 
      - 'jobA'
      - 'jobB'

 steps:
    - name: Create test things.
 env: 
 ENVIRONMENT: 'if github.runs-on == int; then $ENVIRONMENT=integration else $ENVIRONMENT=staging' 
    - name: Test
 run: |
           some command using ${{env.ENVIRONMENT}} 
          - Desired output is integration

           some command using ${{env.ENVIRONMENT}}
          - Desired output is staging

感謝任何願意提供幫助的人!

runs-on用於指定機器名稱 - 您不應在其中放置任何自定義字符串。

正確的格式如下所示:

Test:
 name: Deploy Test
 runs-on: ubuntu-latest
 strategy:
     matrix:
         env: [int, stg]
 needs: 
      - 'jobA'
      - 'jobB'
 steps:
    - name: Create test things.
    - uses: haya14busa/action-cond@v1
      id: env_name
      with:
        cond: ${{ matrix.env == 'int' }}
        if_true: "integration"
        if_false: "staging"
    - name: Test environment name
      run: |
           some command using ${{ matrix.env }} #int / stg will be passed
           echo ${{ steps.env_name.outputs.value }} # will output integration for int, staging for stg
     - name: Test Staging Only
      if: matrix.env == 'stg'
      run: |
           some command using ${{ matrix.env }} #stg only, skipped for int
           # This only executes for staging

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM