Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(versions): alias tags #1513

Merged
merged 2 commits into from
Jul 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions documentation-site/components/version-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ const VersionSelector = () => {
.map(item => {
return {
label: item.name,
commit: item.target_commitish,
};
});

Expand Down Expand Up @@ -84,7 +83,10 @@ const VersionSelector = () => {
items={versionsToShow}
onItemSelect={({item}) => {
window.open(
`https://${item.commit}-baseweb.now.sh`,
`https://${item.label.replace(
/\./gi,
'-',
)}.baseweb.design`,
);
close();
}}
Expand Down
31 changes: 29 additions & 2 deletions now.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
#!/bin/bash

now --scope=uber-ui-platform --token=$ZEIT_NOW_TOKEN --public --no-clipboard deploy ./public > deployment.txt
now --scope=uber-ui-platform --token=$ZEIT_NOW_TOKEN alias `cat deployment.txt` "${BUILDKITE_COMMIT}-baseweb"
set -e

apt-get update
apt-get install -y jq

this_commit=$(echo $BUILDKITE_COMMIT | tr -d '"')
tags=$(curl https://api.github.com/repos/uber-web/baseui/git/refs/tags?access_token=${GITHUB_AUTH_TOKEN})
latest_tagged_commit=$(echo $tags | jq '.[-1].object.sha' | tr -d '"')

echo this commit: $this_commit
echo latest tagged commit: $latest_tagged_commit

if [ "$this_commit" = "$latest_tagged_commit" ]; then
echo current commit matches latest tagged commit
echo deploying to now

$deployment=`cat deployment.txt`
cname="${deployment//./-}"
now --scope=uber-ui-platform --token=$ZEIT_NOW_TOKEN --public --no-clipboard deploy ./public > deployment.txt
now --scope=uber-ui-platform --token=$ZEIT_NOW_TOKEN alias $deployment "$latest_tagged_commit.baseweb.design"
curl -X POST "https://api.cloudflare.com/client/v4/zones/$CF_ZONE_ID/dns_records" \
-H "X-Auth-Email: $CF_AUTH_EMAIL" \
-H "X-Auth-Key: $CF_API_KEY" \
-H "Content-Type: application/json" \
--data "{\"type\":\"CNAME\",\"name\":\"$latest_tagged_commit.baseweb.design\",\"content\":\"alias.zeit.co\",\"ttl\":1,\"priority\":10,\"proxied\":false}"
else
echo current commit does not match latest tagged commit
echo exited without deploying to now
fi