Skip to content

Commit

Permalink
MRG: Merge pull request #16 from octue/remove-gcp-environment-input
Browse files Browse the repository at this point in the history
Remove GCP environment input
  • Loading branch information
cortadocodes authored Feb 6, 2024
2 parents 1d4a51c + 1b0c0c1 commit 5879b07
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 16 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ jobs:
gcp_region: europe-west6
gcp_resource_affix: my-affix
gcp_service_name: my-test-service
gcp_environment: main

- name: Get short SHA
id: get-short-sha
Expand Down
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/get-deployment-info@0.2.3
RUN pip3 install git+https://github.com/octue/get-deployment-info@0.3.0

COPY get_deployment_info/entrypoint.sh /entrypoint.sh

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ steps:

- name: Get deployment info
id: get-deployment-info
uses: octue/get-deployment-info@0.2.3
uses: octue/get-deployment-info@0.3.0
with:
gcp_project_name: test-project
gcp_project_number: 1234
Expand Down
14 changes: 5 additions & 9 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ inputs:
gcp_service_name:
description: "The name of the service being deployed."
required: true
gcp_environment:
description: "The environment in Google Cloud the service is being deployed into e.g. 'staging' or 'production'."
required: false
default: main

outputs:
branch_tag_kebab:
Expand Down Expand Up @@ -58,16 +54,16 @@ outputs:
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."
gcp_service_name:
description: "The name of the service being deployed."
gcp_environment:
description: "The environment in Google Cloud the service is being deployed into e.g. 'staging' or 'production'."

gcp_environment_kebab:
description: "If the branch is 'main', this is 'production'; otherwise it's 'staging'."
gcp_environment_screaming:
description: "If the branch is 'main', this is 'PRODUCTION'; otherwise it's 'STAGING'."
runs:
using: "docker"
image: "docker://octue/get-deployment-info:0.2.3"
image: "docker://octue/get-deployment-info:0.3.0"
args:
- ${{ inputs.gcp_project_name }}
- ${{ inputs.gcp_project_number }}
- ${{ inputs.gcp_region }}
- ${{ inputs.gcp_resource_affix }}
- ${{ inputs.gcp_service_name }}
- ${{ inputs.gcp_environment }}
10 changes: 7 additions & 3 deletions get_deployment_info/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ GCP_PROJECT_NUMBER=$2
GCP_REGION=$3
GCP_RESOURCE_AFFIX=$4
GCP_SERVICE_NAME=$5
GCP_ENVIRONMENT=$6

# Get package version.
if [ -f "pyproject.toml" ]; then VERSION=$(poetry version -s); \
Expand All @@ -23,7 +22,6 @@ echo "gcp_project_number=$GCP_PROJECT_NUMBER" >> $GITHUB_OUTPUT
echo "gcp_region=$GCP_REGION" >> $GITHUB_OUTPUT
echo "gcp_resource_affix=$GCP_RESOURCE_AFFIX" >> $GITHUB_OUTPUT
echo "gcp_service_name=$GCP_SERVICE_NAME" >> $GITHUB_OUTPUT
echo "gcp_environment=$GCP_ENVIRONMENT" >> $GITHUB_OUTPUT

# Get slugified branch name, resource names, and docker image tags.
SHORT_SHA="$(git config --global --add safe.directory /github/workspace && git rev-parse --short HEAD)"
Expand All @@ -39,10 +37,14 @@ if [ "$BRANCH_TAG_KEBAB" = "main" ]; then
REVISION_TAG=$VERSION
IMAGE_VERSION_TAG="$BRANCH_TAG_KEBAB-$REVISION_TAG"
IMAGE_LATEST_TAG="$BRANCH_TAG_KEBAB-latest"
GCP_ENVIRONMENT=production >> $GITHUB_OUTPUT
GCP_ENVIRONMENT_SCREAMING=PRODUCTION >> $GITHUB_OUTPUT
else
REVISION_TAG=$(expr substr "$BRANCH_TAG_KEBAB" 1 12)
IMAGE_VERSION_TAG="$REVISION_TAG"
IMAGE_LATEST_TAG="$REVISION_TAG-latest"
GCP_ENVIRONMENT_KEBAB=staging >> $GITHUB_OUTPUT
GCP_ENVIRONMENT_SCREAMING=STAGING >> $GITHUB_OUTPUT
fi

echo "revision_tag=$REVISION_TAG" >> $GITHUB_OUTPUT
Expand All @@ -59,6 +61,7 @@ echo "image_version_artifact=$IMAGE_VERSION_ARTIFACT" >> $GITHUB_OUTPUT
IMAGE_LATEST_ARTIFACT="$GCP_REGION-docker.pkg.dev/$GCP_PROJECT_NAME/$GCP_RESOURCE_AFFIX/$GCP_SERVICE_NAME:$IMAGE_LATEST_TAG"
echo "image_latest_artifact=$IMAGE_LATEST_ARTIFACT" >> $GITHUB_OUTPUT


# Echo the outputs to stdout to aid debugging.
echo ""
echo "OUTPUTS"
Expand All @@ -79,4 +82,5 @@ echo "- gcp_project_number: $GCP_PROJECT_NUMBER"
echo "- gcp_region: $GCP_REGION"
echo "- gcp_resource_affix: $GCP_RESOURCE_AFFIX"
echo "- gcp_service_name: $GCP_SERVICE_NAME"
echo "- gcp_environment: $GCP_ENVIRONMENT"
echo "- gcp_environment_kebab: $GCP_ENVIRONMENT_KEBAB"
echo "- gcp_environment_screaming: $GCP_ENVIRONMENT_SCREAMING"
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.3"
version = "0.3.0"
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 5879b07

Please sign in to comment.