32
loading...
This website collects cookies to deliver better user experience
Você pode criar uma conta no azure e consumir os créditos para teste, mas nesse artigo os recursos que irei consumir são gratuítos.
Esse projeto utiliza a versão Angular CLI: 12.0.1
az login
az account set --subscription <subscriptionid>
substitua o <nome exclusivo do app> por por exemplo:
coaltimelsv1990, na qual a primeira parte é o nome do app, e a segunda parte são as iniciais do meu nome seguido do ano em que nasci, (Lucas Silvério Vargas, 1990 - lsv1990).
$group="NewCoalTime"
$plan="NewCoaltimePlan"
$app="<nome exlusivo do app>"
az group create -n $group -l eastus2
az appservice plan create -g $group -n $plan -l eastus2 --sku F1 --is-linux
az webapp create -g $group -p $plan -n $app --% --runtime "NODE|14-lts"
az webapp config appsettings set -g $group -n $app --settings WEBSITE_WEBDEPLOY_USE_SCM=true
az webapp config set -g $group -n $app --startup-file="pm2 serve /home/site/wwwroot --no-daemon --spa"
essa operação pode levar alguns minutos para ser concluída
az webapp show -n $app -g $group --query "{url:defaultHostName}" -o tsv
gh auth login
git init
gh repo create $app
git branch -M main
git add .
git commit -m "first commit"
git push -u origin main
essa operação pode levar alguns minutos para ser concluída
Copie o resultado vamos usar no comando a frente.
az webapp deployment list-publishing-profiles -n $app -g $group --xml
gh secret set AZURE_WEBAPP_PUBLISH_PROFILE
md .github/workflows
cd . > .github/workflows/azure.yml
code .
name: "🚀 release"
on:
push:
branches:
- main
env:
AZURE_WEBAPP_NAME: <nome exclusivo do app>
AZURE_WEBAPP_PACKAGE_PATH: './dist/app'
NODE_VERSION: '14.x'
jobs:
build-and-deploy:
name: 🚀 Build and Deploy
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v2
- name: 🟢 Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
- name: ⚡ npm install, build
run: |
npm install
npm run build
- name: '☁ Deploy to Azure WebApp'
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
git add .
git commit -m "first deploy"
git push
A propósito essa comidinhas sou eu que faço, 'nem só de código vive o dev 😀