diff --git a/Dockerfile b/Dockerfile index 184c04a..955582e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM python:3.10.7-slim RUN apt-get update -y && apt-get install -y --fix-missing curl git && rm -rf /var/lib/apt/lists/* -RUN pip3 install git+https://github.com/octue/get-deployment-info@0.2.1 +RUN pip3 install git+https://github.com/octue/get-deployment-info@0.2.2 COPY get_deployment_info/entrypoint.sh /entrypoint.sh diff --git a/README.md b/README.md index 8b6732c..760a144 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ # Get deployment info -A GitHub action that gets the information needed to build and deploy an Octue service to the cloud. This information is -extracted and/or generated from: +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` @@ -25,7 +25,7 @@ steps: - name: Get deployment info id: get-deployment-info - uses: octue/get-deployment-info@0.2.1 + uses: octue/get-deployment-info@0.2.2 with: gcp_project_name: test-project gcp_project_number: 1234 @@ -48,6 +48,8 @@ Outputs can be accessed in the usual way. For example, to print all the outputs: 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 }} @@ -59,3 +61,22 @@ Outputs can be accessed in the usual way. For example, to print all the outputs: 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 `` +- `image_version_tag` is `main-` +- `image_latest_tag` is `main-latest` + +### 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 `pull-` +- `image_version_tag` is `pull-` +- `image_latest_tag` is `pull--latest` diff --git a/action.yaml b/action.yaml index 355116b..2b35361 100644 --- a/action.yaml +++ b/action.yaml @@ -63,7 +63,7 @@ outputs: runs: using: "docker" - image: "docker://octue/get-deployment-info:0.2.1" + image: "docker://octue/get-deployment-info:0.2.2" args: - ${{ inputs.gcp_project_name }} - ${{ inputs.gcp_project_number }} diff --git a/get_deployment_info/entrypoint.sh b/get_deployment_info/entrypoint.sh index a30356d..078aa8b 100644 --- a/get_deployment_info/entrypoint.sh +++ b/get_deployment_info/entrypoint.sh @@ -40,7 +40,7 @@ if [ "$BRANCH_TAG_KEBAB" = "main" ]; then IMAGE_VERSION_TAG="$BRANCH_TAG_KEBAB-$REVISION_TAG" IMAGE_LATEST_TAG="$BRANCH_TAG_KEBAB-latest" else - REVISION_TAG=pull-$(echo $BRANCH_TAG_KEBAB | tr -d -c 0-9) + REVISION_TAG=pull-"${BRANCH_TAG_KEBAB:0:12}" IMAGE_VERSION_TAG="$REVISION_TAG" IMAGE_LATEST_TAG="$REVISION_TAG-latest" fi diff --git a/pyproject.toml b/pyproject.toml index 43f6969..18eb94e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "get-deployment-info" -version = "0.2.1" +version = "0.2.2" description = "A Github Action that gets the information required to build and deploy an Octue service." authors = ["Marcus Lugg "] readme = "README.md"