Skip to content

Instantly share code, notes, and snippets.

View sebastian-schlecht's full-sized avatar
⚙️

Sebastian Schlecht sebastian-schlecht

⚙️
View GitHub Profile
export const withFeatureFlag = (featureFlag: string, defaultValue: boolean) => <P extends object>(
Component: React.ComponentType<P>,
) => {
interface WithFeatureFlagProps {
[featureFlag: string]: boolean | undefined;
}
const WithFeatureFlag: React.FC<P & WithFeatureFlagProps> = props => {
const [flag, setFlag] = useState<boolean>(defaultValue);
// Initial query for feature flag
@sebastian-schlecht
sebastian-schlecht / deploy.sh
Created February 16, 2020 19:33
Dynamic branch deployments.sh
# Notify Github that a deployment has started - we use that for convenience
DEPLOY_ID=$(curl -s -X POST \
-H "Authorization: token $GITHUB_API_TOKEN" \
-H "Accept: application/vnd.github.flash-preview+json" \
-d "{\"ref\": \"$CIRCLE_SHA1\", \"auto_merge\": false, \"environment\": \"$CIRCLE_BRANCH\", \"required_contexts\": [], \"transient_environment\": true}" \
"https://api.github.com/repos/<account>/<reponame>/deployments" | \
python -c "import sys, json; print json.load(sys.stdin)['id']")
# Deploy to zeit.now