Skip to content

Commit

Permalink
Fix the url generation for forks
Browse files Browse the repository at this point in the history
  • Loading branch information
thesan committed Jun 21, 2023
1 parent 6c6fb20 commit 157b4ed
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,23 +118,18 @@ jobs:
- name: Get the Storybook preview deployment url
run: |
PROJECT="pioneer-2-storybook"
PREFIX="git-"
URL_BRANCH=$( \
node \
-e 'process.stdout.write(process.argv[1].replace(/#/g, "").replace(/\W/g, "-").toLowerCase())' \
"$BRANCH" \
)
LONG="$PROJECT-$PREFIX$URL_BRANCH-joystream"
SHORT=$(echo "$LONG" | head -c 46)
SUBDOMAIN=$( \
[ ${#LONG} -le 63 ] \
&& echo "$LONG" \
|| echo "$SHORT-$(echo -n "$PREFIX$BRANCH$PROJECT" | sha256sum | head -c 6)" \
)
URL_BRANCH=$(echo "$BRANCH" | tr -d '#' | tr -c '[:alnum:]' '-' | tr '[:upper:]' '[:lower:]')
SUBDOMAIN="$PROJECT-$PREFIX-$URL_BRANCH-joystream"
if [ ${#LONG} -gt 63 ]; then
[ "$PREFIX" == 'git-fork' ] && BRANCH=$(echo "$BRANCH" | sed 's/:/-/')
HASH=$(echo -n "$PREFIX-$BRANCH$PROJECT" | sha256sum | head -c 6)
SUBDOMAIN="$(echo "$LONG" | head -c 46)-$HASH"
fi
echo "VERCEL_DEPLOYMENT_URL=$SUBDOMAIN.vercel.app" >> "$GITHUB_ENV"
env:
BRANCH: ${{ steps.branch-name.outputs.head_ref_branch }}
PROJECT: pioneer-2-storybook
PREFIX: ${{ github.event.pull_request.head.repo.fork && 'git-fork' || 'git' }}
BRANCH: ${{ github.event.pull_request.head.label ?? github.ref_name }}

- run: echo "$TARGET_URL"
env:
Expand Down

0 comments on commit 157b4ed

Please sign in to comment.