You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
GitHub Action
Select target action
v0.2.0
Configure the matrix job directory in GitHub Label.
For example, create the following labels.
target:all
target:develop
target:staging
target:production
Create a json file in the following format. Specify the label name as key and target directory as value.
The config file name or directory can be specified, but .deploy_target.json
is used by default.
{
"target:develop": [
"envs/dev"
],
"target:staging": [
"envs/stg"
],
"target:production": [
"envs/prod"
],
"target:all" : [
"envs/dev",
"envs/stg",
"envs/prod"
]
}
GitHub Actions are configured as follows:
name: Terraform PR check
on:
pull_request:
types: [opened]
branches:
- main
jobs:
set-matrix:
runs-on: ubuntu-latest
outputs:
workdir: ${{ steps.set_matrix.outputs.matrix-workdir }}
steps:
- name: checkout
uses: actions/checkout@v3
- name: Set matrix
id: set_matrix
uses: ponkio-o/select-target-action@main
plan:
needs: [set-matrix]
name: terraform plan
runs-on: ubuntu-latest
strategy:
matrix:
workdir: ${{fromJson(needs.set-matrix.outputs.workdir)}}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup terraform
uses: hashicorp/setup-terraform@v1
- name: Terraform plan
working-directory: ${{ matrix.workdir }}
run: terraform plan -input=false -no-color
...
The directories set in the key of the given label are merged and returned as an array.
If multiple labels are selected, the values are merged.
All inputs are optional.
Name | Description | Default |
---|---|---|
config_file |
Path to configuration file | .deploy_target.json |
token |
GITHUB_TOKEN or PersonalAccessToken(PAT) |
GITHUB_TOKEN |
The working directory outputs as an array.
["envs/dev","envs/stg","envs/prod"]