Skip to content

Commit

Permalink
DEVX-911
Browse files Browse the repository at this point in the history
Support publishing to prod
  • Loading branch information
sheaphillips committed Nov 30, 2023
1 parent 875e3af commit baa5ebe
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ jobs:
with:
publish: 'true'
bucket_name: ${{ secrets.TECHDOCS_S3_BUCKET_NAME }}
s3_dev_root_path: ${{ vars.TECHDOCS_S3_DEV_ROOT_PATH }}
s3_access_key_id: ${{ secrets.TECHDOCS_AWS_ACCESS_KEY_ID }}
s3_secret_access_key: ${{ secrets.TECHDOCS_AWS_SECRET_ACCESS_KEY }}
s3_region: ${{ secrets.TECHDOCS_AWS_REGION }}
s3_endpoint: ${{ secrets.TECHDOCS_AWS_ENDPOINT }}
entity_namespace: ${{ vars.TECHDOCS_ENTITY_NAMESPACE }}
13 changes: 5 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ inputs:
description: 'Flag to control whether generated documentation is published to shared bucket or not.'
required: true
default: "false"
production:
description: 'Flag to control whether generated documentation is published to production folder in shared bucket.'
required: true
default: "false"
bucket_name: # TECHDOCS_S3_BUCKET_NAME: ${{ secrets.TECHDOCS_S3_BUCKET_NAME }}
description: 'Name of bucket to which documentation should be published.'
required: false # not needed if publish = false
s3_dev_root_path: # TECHDOCS_S3_DEV_ROOT_PATH: ${{ vars.TECHDOCS_S3_DEV_ROOT_PATH }}
description: "Subpath within bucket to which dev documentation should be published."
required: false # not needed if publish = false
default: "dev"
s3_access_key_id: # AWS_ACCESS_KEY_ID: ${{ secrets.TECHDOCS_AWS_ACCESS_KEY_ID }}
description: "Access key id to use to authenticate with S3 endpoint."
required: false # not needed if publish = false
Expand All @@ -25,10 +25,7 @@ inputs:
s3_endpoint: # AWS_ENDPOINT: ${{ secrets.TECHDOCS_AWS_ENDPOINT }}
description: "Address of S3 endpoint"
required: false # not needed if publish = false
entity_namespace: # ENTITY_NAMESPACE: ${{ vars.TECHDOCS_ENTITY_NAMESPACE }}
description: "Backstage catalog namespace into which techdocs entity should be published. Used as a path element in S3."
required: false # not needed if publish = false
default: "default"

runs:
using: 'docker'
image: 'ghcr.io/bcgov/devhub-techdocs-publish:latest'
Expand Down
18 changes: 16 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ ENTITY_NAME=$(cat "$CATALOG_FILE" | yq -r .metadata.name)
ENTITY_KIND=$(cat "$CATALOG_FILE" | yq -r .kind)

# map the local variables from the inputs provided by the Action
ENTITY_NAMESPACE="$INPUT_ENTITY_NAMESPACE"
ENTITY_NAMESPACE="default"
TECHDOCS_S3_BUCKET_NAME="$INPUT_BUCKET_NAME"
TECHDOCS_S3_DEV_ROOT_PATH="$INPUT_S3_DEV_ROOT_PATH"
TECHDOCS_S3_DEV_ROOT_PATH="dev"
AWS_ENDPOINT="$INPUT_S3_ENDPOINT"
export AWS_ACCESS_KEY_ID="$INPUT_S3_ACCESS_KEY_ID"
export AWS_SECRET_ACCESS_KEY="$INPUT_S3_SECRET_ACCESS_KEY"
Expand Down Expand Up @@ -54,12 +54,26 @@ then
echo "AWS_SECRET_ACCESS_KEY is set!"
fi

echo "Publishing TechDocs to DEV..."
techdocs-cli publish --publisher-type awsS3 \
--storage-name "$TECHDOCS_S3_BUCKET_NAME" \
--entity "$ENTITY_PATH" \
--awsEndpoint "$AWS_ENDPOINT" \
--awsS3ForcePathStyle true \
--awsBucketRootPath "$TECHDOCS_S3_DEV_ROOT_PATH"

# only publish to prod (root) folder of bucket if PRODUCTION input is true
if [ "$IMPUT_PRODUCTION" == "true" ]
then
echo "Publishing TechDocs to PROD..."
techdocs-cli publish --publisher-type awsS3 \
--storage-name "$TECHDOCS_S3_BUCKET_NAME" \
--entity "$ENTITY_PATH" \
--awsEndpoint "$AWS_ENDPOINT" \
--awsS3ForcePathStyle true
else
echo "Not publishing TechDocs to PROD."
fi
fi


0 comments on commit baa5ebe

Please sign in to comment.