GitHub Actions for CCAO Data projects.
This repo also includes reusable workflows (stored in the .github/workflows/
directory) and bash scripts to support them (stored in the
.github/workflow/scripts/ directory.)
The following composite actions are available for use:
Install and configure Terraform and AWS for the correct workspace (staging or prod).
- At least one Terraform (
*.tf) config file must exist in the repo. The path to these files can be specified with theworking-directoryinput variable (defaults to"."). - The calling workflow must grant the following permissions to the job that
calls this action:
contents: readid-token: write
- Various required inputs and secrets must be passed in by the calling workflow. See the action file for details.
See the Setup Terraform step in the run job in the
build-and-run-batch-job
workflow.
Delete all AWS resources managed by a Terraform configuration.
See the requirements for setup-terraform.
See the sample usage for setup-terraform.
The following reusable workflows are available for use:
Build a Docker image, push it to the GitHub Container Registry, and then optionally use that container image to run a job on AWS Batch.
The Batch job will only run when the workflow is manually dispatched from the
GitHub UI. Jobs are gated behind an environment called deploy, which can
be configured to require approval before running. This is handy for intensive
jobs that don't need to be run on every commit during development.
An optional cleanup step will run on the pull_request.closed event if the
calling workflow is configured to run on that event as well. This step will
delete all AWS resources provisioned by Terraform. No other steps will run
on pull_request.closed.
The workflow is composed of three jobs:
build: Always runs, except on thepull_request.closedevent. Builds a Docker image and pushes it to GHCR.run: Runs afterbuildonly when manually dispatched and when thedeployenvironment is approved. Provisions a Batch compute environment, job queue, and job definition using the image built in thebuildstep using Terraform, and then kicks off a job using that job definition. Waits for the job to complete before exiting.cleanup: Deletes all AWS resources created by the workflow. Only runs on thepull_request.closedevent, in which case neitherbuildnorrunwill run.
- A Dockerfile must be defined in the root of the repo whose workflow is
calling
build-and-run-batch-job. - An environment called
deploymust be configured in the calling repo. This environment can be used to gate therunjob behind approval. - If you would like the
cleanupstep to run, the calling workflow must be configured to run on thepull_request.closedevent. - Various AWS VPC and IAM resources that are used across jobs are assumed to
already exist. These resources are defined as
dataentities in the Terraform config for the workflow. In the future we could factor this out to make these resource IDs configurable, but for now they are hardcoded to point to the corresponding resources in the CCAO Data AWS organization. See the Terraform config for details. - The calling workflow must grant the following permissions to the job
that calls this workflow:
contents: readid-token: writepackages: write
- Various required inputs and secrets must be passed in by the calling workflow. See the workflow file for details.
See the build-and-run-model workflow in
model-res-avm.