Skip to content

Commit

Permalink
Support Superblocks resources not directly at repo root (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
taha-au authored Mar 7, 2024
1 parent 4880a24 commit ac64faa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 3 additions & 3 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ inputs:
description: 'The Superblocks domain where applications are hosted'
default: 'app.superblocks.com'
path:
description: 'The relative path to the Superblocks config file'
default: '.superblocks/superblocks.json'
description: 'The relative path from repo root to the Superblocks root directory. This is where the ~.superblocks/superblocks.json config file is located.'
default: '.'
sha:
description: 'Commit to pull changes for'
default: 'HEAD'
Expand All @@ -23,5 +23,5 @@ runs:
SUPERBLOCKS_COMMIT_MESSAGE_IDENTIFIER: '[superblocks ci]'
SUPERBLOCKS_TOKEN: ${{ inputs.token }}
SUPERBLOCKS_DOMAIN: ${{ inputs.domain }}
SUPERBLOCKS_CONFIG_PATH: ${{ inputs.path }}
SUPERBLOCKS_PATH: ${{ inputs.path }}
SUPERBLOCKS_COMMIT_SHA: ${{ inputs.sha }}
11 changes: 8 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ readonly SUPERBLOCKS_CLI_VERSION='^1.4.0'

COMMIT_SHA="${COMMIT_SHA:-HEAD}"
SUPERBLOCKS_DOMAIN="${SUPERBLOCKS_DOMAIN:-app.superblocks.com}"
SUPERBLOCKS_CONFIG_PATH="${SUPERBLOCKS_CONFIG_PATH:-.superblocks/superblocks.json}"
SUPERBLOCKS_COMMIT_MESSAGE_IDENTIFIER="${SUPERBLOCKS_COMMIT_MESSAGE_IDENTIFIER:-[superblocks ci]}"
SUPERBLOCKS_PATH="${SUPERBLOCKS_PATH:-.}"

SUPERBLOCKS_CONFIG_RELATIVE_PATH=".superblocks/superblocks.json"

# GitHub Actions default environment variables: https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
if [ "$GITHUB_ACTIONS" == "true" ]; then
Expand Down Expand Up @@ -49,7 +51,10 @@ if [ "$actor_name" != "$SUPERBLOCKS_AUTHOR_NAME" ] && ! echo "$commit_message" |
fi

# Get the list of changed files in the last commit
changed_files=$(git diff "${COMMIT_SHA}"^ --name-only)
changed_files=$(git diff "${COMMIT_SHA}"^ --name-only -- "$SUPERBLOCKS_PATH")

# Change the working directory to the Superblocks path
pushd "$SUPERBLOCKS_PATH"

if [ -n "$changed_files" ]; then
# Install Superblocks CLI
Expand Down Expand Up @@ -103,7 +108,7 @@ pull_and_commit() {
}

# Check if any Superblocks applications have changed
jq -r '.resources[] | select(.resourceType == "APPLICATION") | .location' "$SUPERBLOCKS_CONFIG_PATH" | while read -r location; do
jq -r '.resources[] | select(.resourceType == "APPLICATION") | .location' "$SUPERBLOCKS_CONFIG_RELATIVE_PATH" | while read -r location; do
printf "\nChecking %s for changes...\n" "$location"
pull_and_commit "$location"
done
Expand Down

0 comments on commit ac64faa

Please sign in to comment.