Skip to content

Add a GitHub workflow

The terraform-on-changed-dirs workflow is a GitHub Action that triggers when changes are made within configured stacks. This workflow is used to deploy the infrastructure changes to the environment in AWS.

Step 1: Create a new configuration file

In the repo-iac/.github/workflows/_config/dev/ folder, create a new configuration file for the terraform-on-changed-dirs workflow:

ok pkg add terraform-on-changed-dirs

Step 1: Update the configuration file

Update the configuration file for the Terraform-on-changed-dirs workflow:

repo-iac/.github/workflows/_config/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: Install the terraform-on-changed-dirs package

repo-iac/.github/workflows/_config/dev/
ok pkg install ../..

Step 3: Verify

Verify that the workflow file repo-iac/.github/workflows/_gp_pirates-dev_terraform_on_changed_dirs.yml has been created.

Commit your files

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

Next step

Create encryption keys.