Skip to content

Commit

Permalink
Merge pull request #18 from octue/fix-environment-outputs
Browse files Browse the repository at this point in the history
Update entrypoint.sh
  • Loading branch information
thclark authored Feb 6, 2024
2 parents c495298 + 637e582 commit 29e7a8f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 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/get-deployment-info@0.3.1
RUN pip3 install git+https://github.com/octue/get-deployment-info@0.3.2

COPY get_deployment_info/entrypoint.sh /entrypoint.sh

Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ steps:
gcp_region: europe-west1
gcp_resource_affix: test
gcp_service_name: my-test-service
gcp_environment: main
```
Outputs can be accessed in the usual way. For example, to print all the outputs:
Expand All @@ -50,7 +49,8 @@ Outputs can be accessed in the usual way. For example, to print all the outputs:
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_environment_kebab }}
echo ${{ steps.get-deployment-info.outputs.gcp_environment_screaming }}
echo ${{ steps.get-deployment-info.outputs.gcp_project_name }}
echo ${{ steps.get-deployment-info.outputs.gcp_project_number }}
echo ${{ steps.get-deployment-info.outputs.gcp_region }}
Expand All @@ -71,6 +71,8 @@ Some of the outputs' values depend on whether the action is run on the `main` br
- `revision_tag` is `<version>`
- `image_version_tag` is `main-<version>`
- `image_latest_tag` is `main-latest`
- `gcp_environment_kebab` is `production`
- `gcp_environment_screaming` is `PRODUCTION`

### Non-main branch deployments

Expand All @@ -80,3 +82,5 @@ Cloud Run without having to restrict the length of branch names.
- `revision_tag` is `<truncated branch_tag_kebab>`
- `image_version_tag` is `<truncated branch_tag_kebab>`
- `image_latest_tag` is `<truncated branch_tag_kebab>-latest`
- `gcp_environment_kebab` is `staging`
- `gcp_environment_screaming` is `STAGING`
1 change: 1 addition & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ outputs:
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.3.1"
Expand Down
10 changes: 6 additions & 4 deletions get_deployment_info/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,21 @@ 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_KEBAB=production >> $GITHUB_OUTPUT
GCP_ENVIRONMENT_SCREAMING=PRODUCTION >> $GITHUB_OUTPUT
GCP_ENVIRONMENT_KEBAB="production"
GCP_ENVIRONMENT_SCREAMING="PRODUCTION"
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
GCP_ENVIRONMENT_KEBAB="staging"
GCP_ENVIRONMENT_SCREAMING="STAGING"
fi

echo "revision_tag=$REVISION_TAG" >> $GITHUB_OUTPUT
echo "image_version_tag=$IMAGE_VERSION_TAG" >> $GITHUB_OUTPUT
echo "image_latest_tag=$IMAGE_LATEST_TAG" >> $GITHUB_OUTPUT
echo "gcp_environment_kebab=$GCP_ENVIRONMENT_KEBAB" >> $GITHUB_OUTPUT
echo "gcp_environment_screaming=$GCP_ENVIRONMENT_SCREAMING" >> $GITHUB_OUTPUT

REVISION_TAG_SLUG=$(echo $REVISION_TAG | tr . -)
echo "revision_tag_slug=$REVISION_TAG_SLUG" >> $GITHUB_OUTPUT
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.3.1"
version = "0.3.2"
description = "A Github Action that gets the information required to build and deploy an Octue service."
authors = ["Marcus Lugg <marcus@octue.com>"]
readme = "README.md"
Expand Down

0 comments on commit 29e7a8f

Please sign in to comment.