Github Actions 矩阵问题

阿萨夫

我只希望它在 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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章