Skip to content

Add a GitHub workflow

Set up a workflow that listens for events from your application repository. When it receives an event, it commits the new image tag to the infrastructure repository.

Step 1: Update configuration

Set ExampleImage to false in the configuration file to deploy a custom Docker image instead of the example image.

repo-iac/environments/dev/app-too-tikki/package-config.yml
ExampleImage:
- Enable: true
+ Enable: false

Update code:

repo-iac/environments/dev/app-too-tikki/
ok pkg install

Step 2: Create metadata file

Create a metadata file to store the image tag and digest. Add it to the app-too-tikki directory of your IaC repository.

The initial values aren't important—we'll update them automatically.

repo-iac/environments/dev/app-too-tikki/__gp_config_app_image.auto.tfvars.json
{
  "main_container_image_digest": "sha256:2eb61545144b6c60eae0a7ae6d622cdd3bb205124f0054cbc3ad799516b67c1a",
  "main_container_image_tag": "sha-cbd6a43f973802a3dc60ed55ecf43f8a817bdd54"
}

Step 3: Create configuration file

Create a configuration file for the receive-dispatch workflow in the repo-iac/.github/workflows/_config/dev/ folder:

repo-iac/.github/workflows/_config/dev/
ok pkg add receive-dispatch-event too-tikki_receive-dispatch-event

Step 4: Update configuration file

Update the receive-dispatch-event workflow configuration:

repo-iac/.github/workflows/_config/dev/too-tikki_receive-dispatch-event.yml
AppName: "too-tikki"
CreatePr: true
GpgSign: true
WorkingDirectory: "environments/dev/app-{{ .AppName }}"
ImageMetadataFile: "__gp_config_app_image.auto.tfvars.json"

Step 5: Install package

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

Step 6: Verify

Check that the IaC repository contains the new workflow file at repo-iac/.github/workflows/_gp_too-tikki_pirates-dev_receive_dispatch_event.yml.

The outcome values from configure the workflow should appear in the new workflow file.

Commit your files

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

Step 7: Test the workflow

Build a new image to run the workflow chain. The receiving workflow will fail because you haven't configured a PAT and GPG key yet. The next section covers this.

Next step

Add PAT as a secret to the infrastructure repository.