GitHub Action
Get deployment information
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
orsetup.py
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
gcp_environment: main
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 }}
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_tag
is<version>
image_version_tag
ismain-<version>
image_latest_tag
ismain-latest
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
ispull-<truncated branch_tag_kebab>
image_version_tag
ispull-<truncated branch_tag_kebab>
image_latest_tag
ispull-<truncated branch_tag_kebab>-latest