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
gitpyproject.tomlorsetup.py
Add the action as a step in your workflow:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install poetry
uses: snok/install-poetry@v1
- 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-serviceOutputs 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.image_default_artifact }}
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.
Some of the outputs' values depend on whether the action is run on the main branch or a non-main branch.
revision_tagis<version>image_version_tagis<version>image_latest_tagislatestgcp_environment_kebabisproductiongcp_environment_screamingisPRODUCTION
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_tagis<truncated branch_tag_kebab>image_version_tagis<truncated branch_tag_kebab>image_latest_tagis<truncated branch_tag_kebab>-latestgcp_environment_kebabisstaginggcp_environment_screamingisSTAGING