Skip to content

Commit

Permalink
MRG: Merge pull request #14 from octue/use-truncated-branch-or-pull-n…
Browse files Browse the repository at this point in the history
…ame-in-revision-tag

Use truncated branch or pull request name for revision tag for non-main deployments
  • Loading branch information
cortadocodes authored Jan 29, 2024
2 parents f83ccd4 + 1a97faf commit 25179fd
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected].1
RUN pip3 install git+https://github.com/octue/[email protected].2

COPY get_deployment_info/entrypoint.sh /entrypoint.sh

Expand Down
27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -25,7 +25,7 @@ steps:

- name: Get deployment info
id: get-deployment-info
uses: octue/[email protected].1
uses: octue/[email protected].2
with:
gcp_project_name: test-project
gcp_project_number: 1234
Expand All @@ -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 }}
Expand All @@ -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 `<version>`
- `image_version_tag` is `main-<version>`
- `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-<truncated branch_tag_kebab>`
- `image_version_tag` is `pull-<truncated branch_tag_kebab>`
- `image_latest_tag` is `pull-<truncated branch_tag_kebab>-latest`
2 changes: 1 addition & 1 deletion action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion get_deployment_info/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit 25179fd

Please sign in to comment.