Skip to content

Add a GitHub workflow

The terraform-on-changed-dirs workflow is configured based on environment.

You should achieve the following outcome after completing this page:

Configuration
Environment pirates-dev
Outcome
Workflow file .github/workflows/_gp_pirates-dev_terraform_on_changed_dirs.yml

Step 1: Create configuration file

repo-iac/.github/workflows/environments/dev/terraform-on-changed-dirs.yml
FileTypes:
  - "**.tf"
  - "**.json"
StacksRootDir: "environments/dev"
Stacks:
  - name: "app-too-tikki"
    githubEnvironment: "pirates-dev-app-too-tikki-cicd"
  • FileTypes defines which files you want the workflow to trigger on
  • StacksRootDir is the root directory for your stacks in the environment
  • Stacks is a list of stacks that you want to trigger on. Each stack has a name (matching the stack directory name) and a githubEnvironment that corresponds to the outcome when you added a GitHub environment .

Step 2: Fetch the terraform-on-changed-dirs template

repo-iac/.github/workflows/environments/dev/
boilerplate \
--template-url "git@github.com:oslokommune/golden-path-boilerplate.git//boilerplate/github-actions/terraform-on-changed-dirs/?ref=main" \
--var-file terraform-on-changed-dirs.yml \
--var-file common-config.yml \
--output-folder ../../ \
--non-interactive

Note: since terraform-on-changed-dirs.yml is a Environment configuration file, it should be placed in the environments/dev directory, and the boilerplate command must be executed from this directory.

Step 3: Verify

Verify that the workflow file .github/workflows/_gp_pirates-dev_terraform_on_changed_dirs.ym has been created.

Commit your files

At this stage it is a good idea to commit your files.

Next step

Create encryption keys.