Shell Github操作使用相同的矩阵配置运行的作业
我不熟悉Github操作,并尝试通过Github操作在AWS多区域上部署代码。 为此,我创建了一个包含此矩阵的脚本,并将输出导出到工作流Shell Github操作使用相同的矩阵配置运行的作业,shell,continuous-integration,github-actions,terraform-aws-modules,Shell,Continuous Integration,Github Actions,Terraform Aws Modules,我不熟悉Github操作,并尝试通过Github操作在AWS多区域上部署代码。 为此,我创建了一个包含此矩阵的脚本,并将输出导出到工作流 APP_DEPLOY_TO_DEV=' { "environment": ["app_dev_eu-central-1", "app_dev_us-east-1" ], "include":[ { "aws_env
APP_DEPLOY_TO_DEV='
{
"environment": ["app_dev_eu-central-1", "app_dev_us-east-1" ],
"include":[
{
"aws_env": "app_dev_eu-central-1",
"aws_region": "eu-central-1",
},
{
"aws_env": "app_dev_us-east-1",
"aws_region": "us-east-1",
}
]
}'
MATRIX_PARAMS_COMBINATIONS=$APP_DEPLOY_TO_DEV
echo ::set-output name=matrix_combinations::$MATRIX_PARAMS_COMBINATIONS
我的工作流程代码:
- name: SetUp Matrix Combinations
id: matrix
run: |
chmod +x app_deploy.sh; ./app_deploy.sh
working-directory: .github/scripts
shell: bash
outputs:
matrix-combinations: ${{ steps.matrix.outputs.matrix-combinations }}
build-deploy:
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [Setup-Matrix]
strategy:
matrix: ${{ fromJson(needs.Setup-Matrix.outputs.matrix-combinations) }}
steps:
- name: Print Combinations
run: |
echo "step output"
echo "${{ matrix.aws_env }}"; // here app_dev_us-east-1 is getting printed instead of array
echo "op ${{ toJson(needs.Setup-Matrix.outputs.matrix-combinations) }}" //I am getting proper json array here
我使用${{matrix.variable_names}}
访问矩阵值
但当我看到我的工作时,有两个工作正在创建,但配置是相同的(它将我们带到东部1)。不确定可能出了什么问题。以前,我尝试使用StrategyMatrix,后来我改为使用shell脚本,因为我有多个if检查,这使我的工作流看起来很笨拙。任何潜在客户都将不胜感激:)与其说是aws_env,不如说是environment