Created
June 29, 2022 05:39
-
-
Save vegaasen/d0e77cbbaf9e8a3711b84847d7cbb841 to your computer and use it in GitHub Desktop.
Azure Static Web App (SWA) Deployer π
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# In the future, when Azure fixes its `swa deploy build` command, we have to rely on this style (unfortunately) | |
# Whilst we're waiting for this to be fixed, lets rely on this script instead | |
apiTokenFile=.api-token | |
you=$(git config --get user.name) | |
theGitBranch=$(git branch --show-current) | |
theGitCommit=$(git rev-parse --short HEAD) | |
applicationName=$(pwd | awk -F/ '{print $NF}') | |
if [ ! "$(command -v swa)" ]; then | |
echo "π©βοΈ Oh no! No swa <command> found! Install this tool first using e.g npm i -g @azure/static-web-apps-cli" | |
exit 1 | |
fi | |
echo "β³ Building application" | |
npm run build | |
echo "β³ Choose environment" | |
swa deploy --print-token | tee ${apiTokenFile} | |
if [ ! -f ${apiTokenFile} ]; then | |
echo "π’ No token-file on ${apiTokenFile}" | |
exit 1 | |
fi | |
apiToken=$(tail -n 1 ${apiTokenFile}) | |
rm ${apiTokenFile} | |
if [ -z "${apiToken}" ]; then | |
echo "π’ No token" | |
exit 1 | |
fi | |
echo "β³ Deploying using token ${apiToken}" | |
docker run -it --rm -e APP_LOCATION="/frontend" -e SKIP_APP_BUILD=true -e DEPLOYMENT_TOKEN="${apiToken}" -v "${PWD}/build:/frontend" mcr.microsoft.com/appsvc/staticappsclient:latest ./bin/staticsites/StaticSitesClient upload | |
echo "π Application deployed on $(date)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment