Skip to content

Release pre-commit black

Get deployment info

A GitHub action that gets the information needed to build and deploy an Octue service to the cloud from a main/production branch or a non-main/development branch. The required information is extracted and/or generated from:

  • The action inputs
  • git
  • pyproject.toml or setup.py

Usage

Add the action as a step in your workflow:

steps:
  - name: Checkout
    uses: actions/checkout@v3

  - name: Install poetry
    uses: snok/[email protected]

  - name: Get deployment info
    id: get-deployment-info
    uses: octue/[email protected]
    with:
      gcp_project_name: test-project
      gcp_project_number: 1234
      gcp_region: europe-west1
      gcp_resource_affix: test
      gcp_service_name: my-test-service

Outputs can be accessed in the usual way. For example, to print all the outputs:

- name: Print outputs
  run: |
    echo ${{ steps.get-deployment-info.outputs.branch_tag_kebab }}
    echo ${{ steps.get-deployment-info.outputs.branch_tag_screaming }}
    echo ${{ steps.get-deployment-info.outputs.image_latest_artifact }}
    echo ${{ steps.get-deployment-info.outputs.image_latest_tag }}
    echo ${{ steps.get-deployment-info.outputs.image_version_artifact }}
    echo ${{ steps.get-deployment-info.outputs.image_version_tag }}
    echo ${{ steps.get-deployment-info.outputs.short_sha }}
    echo ${{ steps.get-deployment-info.outputs.version_slug }}
    echo ${{ steps.get-deployment-info.outputs.revision_tag }}
    echo ${{ steps.get-deployment-info.outputs.revision_tag_slug }}
    echo ${{ steps.get-deployment-info.outputs.gcp_environment_kebab }}
    echo ${{ steps.get-deployment-info.outputs.gcp_environment_screaming }}
    echo ${{ steps.get-deployment-info.outputs.gcp_project_name }}
    echo ${{ steps.get-deployment-info.outputs.gcp_project_number }}
    echo ${{ steps.get-deployment-info.outputs.gcp_region }}
    echo ${{ steps.get-deployment-info.outputs.gcp_resource_affix }}
    echo ${{ steps.get-deployment-info.outputs.gcp_service_name }}
    echo ${{ steps.get-deployment-info.outputs.version }}

Note: there's no need to print the outputs for debugging in practice - the action prints them to stdout for this very purpose.

Main vs non-main branch deployments

Some of the outputs' values depend on whether the action is run on the main branch or a non-main branch.

Main branch deployments

  • revision_tag is <version>
  • image_version_tag is main-<version>
  • image_latest_tag is main-latest
  • gcp_environment_kebab is production
  • gcp_environment_screaming is PRODUCTION

Non-main branch deployments

The truncated branch name (first 12 characters) is used to ensure service names are short enough to be accepted by e.g. Cloud Run without having to restrict the length of branch names.

  • revision_tag is <truncated branch_tag_kebab>
  • image_version_tag is <truncated branch_tag_kebab>
  • image_latest_tag is <truncated branch_tag_kebab>-latest
  • gcp_environment_kebab is staging
  • gcp_environment_screaming is STAGING