Skip to content

Commit

Permalink
Add validation for env vars and make input names consistent (#657)
Browse files Browse the repository at this point in the history
  • Loading branch information
chainchad authored Oct 4, 2024
1 parent ac2bf8a commit 017fa90
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/strong-shirts-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"md-confluence-sync": patch
---

Update input and validate env vars
6 changes: 3 additions & 3 deletions actions/md-confluence-sync/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ inputs:
"use specified markdown file(s) for converting to html. Supports file
globbing patterns"
required: true
base_url:
base-url:
description: "Confluence base url e.g: https://example.com/wiki/"
required: true
user:
Expand Down Expand Up @@ -63,7 +63,7 @@ runs:
fetch-depth: ${{ inputs.checkout-repo-fetch-depth }}

- name: Lint MD files using Prettier
uses: smartcontractkit/.github/actions/ci-prettier@a738d4cfa4826d6f44dbebcc3724385f6de58d42 # v0.1.1
uses: smartcontractkit/.github/actions/ci-prettier@a738d4cfa4826d6f44dbebcc3724385f6de58d42 # ci-prettier@0.1.1
with:
basic-auth: ${{ inputs.gc-basic-auth }}
checkout-repo: "false"
Expand All @@ -83,7 +83,7 @@ runs:
- name: Sync docs
env:
FILES: ${{ inputs.files }}
BASE_URL: ${{ inputs.base_url }}
BASE_URL: ${{ inputs.base-url }}
USER: ${{ inputs.user }}
TOKEN: ${{ inputs.token }}
SPACE: ${{ inputs.space }}
Expand Down
40 changes: 36 additions & 4 deletions actions/md-confluence-sync/mark-sync.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,42 @@
#!/usr/bin/env bash
set -euo pipefail

# $USER is your smartcontract email
# $PASSWORD is the api token created on the https://id.atlassian.com/manage-profile/security/api-tokens page
# Mermaid diagrams are rendered locally and inlined into the HTML artifact as PNGs
##
# Validation
##

if [[ -z "${FILES:-}" ]]; then
echo "FILES is not set. Exiting."
exit 1
fi

# $USER is the email address associated with the token.
if [[ -z "${USER:-}" ]]; then
echo "USER is not set. Exiting."
exit 1
fi

if [[ -z "${TOKEN:-}" ]]; then
echo "TOKEN is not set. Exiting."
exit 1
fi

if [[ -z "${BASE_URL:-}" ]]; then
echo "BASE_URL is not set. Exiting."
exit 1
fi

if [[ -z "${SPACE:-}" ]]; then
echo "SPACE is not set. Exiting."
exit 1
fi

if [[ -z "${PARENT:-}" ]]; then
echo "PARENT is not set. Exiting."
exit 1
fi

# Mermaid diagrams are rendered locally and inlined into the HTML artifact as PNGs.
mark -f "$FILES" \
--edit-lock \
--title-from-h1 \
Expand All @@ -14,4 +46,4 @@ mark -f "$FILES" \
--space "$SPACE" \
--parents "$PARENT" \
--mermaid-provider mermaid-go \
--ci
--ci

0 comments on commit 017fa90

Please sign in to comment.