Skip to content

Commit cf7beef

Browse files
authored
MRG: Merge pull request #4 from octue/enhancement/echo-outputs-to-stdout
Print outputs to `stdout` as part of action
2 parents f919a0f + 2c0fcb7 commit cf7beef

File tree

6 files changed

+49
-40
lines changed

6 files changed

+49
-40
lines changed

.github/workflows/test.yml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,6 @@ jobs:
2929
gcp_service_name: my-test-service
3030
gcp_environment: main
3131

32-
- name: Print outputs
33-
run: |
34-
echo ${{ steps.get-deployment-info.outputs.branch_tag_kebab }}
35-
echo ${{ steps.get-deployment-info.outputs.branch_tag_screaming }}
36-
echo ${{ steps.get-deployment-info.outputs.image_latest_artefact }}
37-
echo ${{ steps.get-deployment-info.outputs.image_latest_tag }}
38-
echo ${{ steps.get-deployment-info.outputs.image_version_artefact }}
39-
echo ${{ steps.get-deployment-info.outputs.image_version_tag }}
40-
echo ${{ steps.get-deployment-info.outputs.short_sha }}
41-
echo ${{ steps.get-deployment-info.outputs.version_slug }}
42-
echo ${{ steps.get-deployment-info.outputs.gcp_environment }}
43-
echo ${{ steps.get-deployment-info.outputs.gcp_project_name }}
44-
echo ${{ steps.get-deployment-info.outputs.gcp_project_number }}
45-
echo ${{ steps.get-deployment-info.outputs.gcp_region }}
46-
echo ${{ steps.get-deployment-info.outputs.gcp_resource_affix }}
47-
echo ${{ steps.get-deployment-info.outputs.gcp_service_name }}
48-
echo ${{ steps.get-deployment-info.outputs.version }}
49-
5032
- name: Get package version
5133
id: get-package-version
5234
run: echo "PACKAGE_VERSION=$(poetry version -s)" >> $GITHUB_OUTPUT

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].0
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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ steps:
2525

2626
- name: Get deployment info
2727
id: get-deployment-info
28-
uses: octue/get-deployment-info
28+
uses: octue/get-deployment-info@0.1.2
2929
with:
3030
gcp_project_name: test-project
3131
gcp_project_number: 1234
@@ -56,3 +56,6 @@ Outputs can be accessed in the usual way. For example, to print all the outputs:
5656
echo ${{ steps.get-deployment-info.outputs.gcp_service_name }}
5757
echo ${{ steps.get-deployment-info.outputs.version }}
5858
```
59+
60+
Note: there's no need to print the outputs for debugging in practice - the action prints them to `stdout` for this very
61+
purpose.

action.yaml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: "Get deployment information"
22
description: "Get the information required to build and deploy an Octue service."
33
author: "cortadocodes"
4-
#branding:
5-
# icon: git-pull-request
6-
# color: green
4+
branding:
5+
icon: cloud
6+
color: red
77
inputs:
88
gcp_project_name:
99
description: "The name of the Google Cloud project being deployed to."
@@ -15,13 +15,13 @@ inputs:
1515
description: "The Google Cloud region being deployed to."
1616
required: true
1717
gcp_resource_affix:
18-
description: ""
18+
description: "A label to affix to the names of the resources created during deployment. This helps avoid confusion about what resources belong to what applications and aids cleanup of old resources."
1919
required: true
2020
gcp_service_name:
2121
description: "The name of the service being deployed."
2222
required: true
2323
gcp_environment:
24-
description: ""
24+
description: "The environment in Google Cloud the service is being deployed into e.g. 'staging' or 'production'."
2525
required: false
2626
default: main
2727

@@ -40,26 +40,26 @@ outputs:
4040
description: "The tag of the docker image for the version."
4141
short_sha:
4242
description: "The short SHA of the HEAD commit being deployed."
43+
version:
44+
description: "The version being deployed."
4345
version_slug:
4446
description: "The slugified version."
45-
gcp_environment:
46-
description: ""
4747
gcp_project_name:
48-
description: ""
48+
description: "The name of the Google Cloud project being deployed to."
4949
gcp_project_number:
50-
description: ""
50+
description: "The number of the Google Cloud project being deployed to."
5151
gcp_region:
52-
description: ""
52+
description: "The Google Cloud region being deployed to."
5353
gcp_resource_affix:
54-
description: ""
55-
gcp_service:
56-
description: ""
57-
version:
58-
description: "The version being deployed."
54+
description: "A label to affix to the names of the resources created during deployment. This helps avoid confusion about what resources belong to what applications and aids cleanup of old resources."
55+
gcp_service_name:
56+
description: "The name of the service being deployed."
57+
gcp_environment:
58+
description: "The environment in Google Cloud the service is being deployed into e.g. 'staging' or 'production'."
5959

6060
runs:
6161
using: "docker"
62-
image: "docker://octue/get-deployment-info:0.1.0"
62+
image: "docker://octue/get-deployment-info:0.1.2"
6363
args:
6464
- ${{ inputs.gcp_project_name }}
6565
- ${{ inputs.gcp_project_number }}

get_deployment_info/entrypoint.sh

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ echo "gcp_service_name=$GCP_SERVICE_NAME" >> $GITHUB_OUTPUT
2424
echo "gcp_environment=$GCP_ENVIRONMENT" >> $GITHUB_OUTPUT
2525

2626
# Get slugified branch name, resource names, and docker image tags.
27-
echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
27+
SHORT_SHA="$(git rev-parse --short HEAD)"
28+
echo "short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT
2829

2930
BRANCH_TAG_KEBAB=$(echo ${GITHUB_REF#refs/heads/} | iconv -c -t ascii//TRANSLIT | sed -E 's/[~^]+//g' | sed -E 's/[^a-zA-Z0-9]+/-/g' | sed -E 's/^-+|-+$//g' | tr A-Z a-z)
3031
echo "branch_tag_kebab=$BRANCH_TAG_KEBAB" >> $GITHUB_OUTPUT
@@ -48,5 +49,28 @@ IMAGE_LATEST_TAG="$BRANCH_TAG_KEBAB-latest"
4849
echo "image_latest_tag=$IMAGE_LATEST_TAG" >> $GITHUB_OUTPUT
4950

5051
# Set image artefact addresses.
51-
echo "image_version_artefact=$GCP_REGION-docker.pkg.dev/$GCP_PROJECT_NAME/$GCP_RESOURCE_AFFIX/$GCP_SERVICE_NAME:$IMAGE_VERSION_TAG" >> $GITHUB_OUTPUT
52-
echo "image_latest_artefact=$GCP_REGION-docker.pkg.dev/$GCP_PROJECT_NAME/$GCP_RESOURCE_AFFIX/$GCP_SERVICE_NAME:$IMAGE_LATEST_TAG" >> $GITHUB_OUTPUT
52+
IMAGE_VERSION_ARTEFACT="$GCP_REGION-docker.pkg.dev/$GCP_PROJECT_NAME/$GCP_RESOURCE_AFFIX/$GCP_SERVICE_NAME:$IMAGE_VERSION_TAG"
53+
echo "image_version_artefact=$IMAGE_VERSION_ARTEFACT" >> $GITHUB_OUTPUT
54+
55+
IMAGE_LATEST_ARTEFACT="$GCP_REGION-docker.pkg.dev/$GCP_PROJECT_NAME/$GCP_RESOURCE_AFFIX/$GCP_SERVICE_NAME:$IMAGE_LATEST_TAG"
56+
echo "image_latest_artefact=$IMAGE_LATEST_ARTEFACT" >> $GITHUB_OUTPUT
57+
58+
# Echo the outputs to stdout to aid debugging.
59+
echo ""
60+
echo "OUTPUTS"
61+
echo "======="
62+
echo "- branch_tag_kebab: $BRANCH_TAG_KEBAB"
63+
echo "- branch_tag_screaming: $BRANCH_TAG_SCREAMING"
64+
echo "- image_latest_artefact: $IMAGE_LATEST_ARTEFACT"
65+
echo "- image_latest_tag: $IMAGE_LATEST_TAG"
66+
echo "- image_version_artefact: $IMAGE_VERSION_ARTEFACT"
67+
echo "- image_version_tag: $IMAGE_VERSION_TAG"
68+
echo "- short_sha: $SHORT_SHA"
69+
echo "- version_slug: $VERSION_SLUG"
70+
echo "- version: $VERSION"
71+
echo "- gcp_project_name: $GCP_PROJECT_NAME"
72+
echo "- gcp_project_number: $GCP_PROJECT_NUMBER"
73+
echo "- gcp_region: $GCP_REGION"
74+
echo "- gcp_resource_affix: $GCP_RESOURCE_AFFIX"
75+
echo "- gcp_service_name: $GCP_SERVICE_NAME"
76+
echo "- gcp_environment: $GCP_ENVIRONMENT"

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.1.1"
3+
version = "0.1.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)