Skip to content

Commit 25179fd

Browse files
authored
MRG: Merge pull request #14 from octue/use-truncated-branch-or-pull-name-in-revision-tag
Use truncated branch or pull request name for revision tag for non-main deployments
2 parents f83ccd4 + 1a97faf commit 25179fd

File tree

5 files changed

+28
-7
lines changed

5 files changed

+28
-7
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM python:3.10.7-slim
22

33
RUN apt-get update -y && apt-get install -y --fix-missing curl git && rm -rf /var/lib/apt/lists/*
44

5-
RUN pip3 install git+https://github.com/octue/[email protected].1
5+
RUN pip3 install git+https://github.com/octue/[email protected].2
66

77
COPY get_deployment_info/entrypoint.sh /entrypoint.sh
88

README.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
# Get deployment info
66

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

1010
- The action inputs
1111
- `git`
@@ -25,7 +25,7 @@ steps:
2525

2626
- name: Get deployment info
2727
id: get-deployment-info
28-
uses: octue/[email protected].1
28+
uses: octue/[email protected].2
2929
with:
3030
gcp_project_name: test-project
3131
gcp_project_number: 1234
@@ -48,6 +48,8 @@ Outputs can be accessed in the usual way. For example, to print all the outputs:
4848
echo ${{ steps.get-deployment-info.outputs.image_version_tag }}
4949
echo ${{ steps.get-deployment-info.outputs.short_sha }}
5050
echo ${{ steps.get-deployment-info.outputs.version_slug }}
51+
echo ${{ steps.get-deployment-info.outputs.revision_tag }}
52+
echo ${{ steps.get-deployment-info.outputs.revision_tag_slug }}
5153
echo ${{ steps.get-deployment-info.outputs.gcp_environment }}
5254
echo ${{ steps.get-deployment-info.outputs.gcp_project_name }}
5355
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:
5961
6062
Note: there's no need to print the outputs for debugging in practice - the action prints them to `stdout` for this very
6163
purpose.
64+
65+
## Main vs non-main branch deployments
66+
67+
Some of the outputs' values depend on whether the action is run on the `main` branch or a non-`main` branch.
68+
69+
### Main branch deployments
70+
71+
- `revision_tag` is `<version>`
72+
- `image_version_tag` is `main-<version>`
73+
- `image_latest_tag` is `main-latest`
74+
75+
### Non-main branch deployments
76+
77+
The truncated branch name (first 12 characters) is used to ensure service names are short enough to be accepted by e.g.
78+
Cloud Run without having to restrict the length of branch names.
79+
80+
- `revision_tag` is `pull-<truncated branch_tag_kebab>`
81+
- `image_version_tag` is `pull-<truncated branch_tag_kebab>`
82+
- `image_latest_tag` is `pull-<truncated branch_tag_kebab>-latest`

action.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ outputs:
6363

6464
runs:
6565
using: "docker"
66-
image: "docker://octue/get-deployment-info:0.2.1"
66+
image: "docker://octue/get-deployment-info:0.2.2"
6767
args:
6868
- ${{ inputs.gcp_project_name }}
6969
- ${{ inputs.gcp_project_number }}

get_deployment_info/entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ if [ "$BRANCH_TAG_KEBAB" = "main" ]; then
4040
IMAGE_VERSION_TAG="$BRANCH_TAG_KEBAB-$REVISION_TAG"
4141
IMAGE_LATEST_TAG="$BRANCH_TAG_KEBAB-latest"
4242
else
43-
REVISION_TAG=pull-$(echo $BRANCH_TAG_KEBAB | tr -d -c 0-9)
43+
REVISION_TAG=pull-"${BRANCH_TAG_KEBAB:0:12}"
4444
IMAGE_VERSION_TAG="$REVISION_TAG"
4545
IMAGE_LATEST_TAG="$REVISION_TAG-latest"
4646
fi

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "get-deployment-info"
3-
version = "0.2.1"
3+
version = "0.2.2"
44
description = "A Github Action that gets the information required to build and deploy an Octue service."
55
authors = ["Marcus Lugg <[email protected]>"]
66
readme = "README.md"

0 commit comments

Comments
 (0)