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.
ExampleImage:
- Enable: true
+ Enable: false
Update code:
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.
{
"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:
ok pkg add receive-dispatch-event too-tikki_receive-dispatch-event
Step 4: Update configuration file
Update the receive-dispatch-event workflow configuration:
AppName: "too-tikki"
CreatePr: true
GpgSign: true
WorkingDirectory: "environments/dev/app-{{ .AppName }}"
ImageMetadataFile: "__gp_config_app_image.auto.tfvars.json"
Step 5: Install package
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.