Em um artigo anterior (em português), abordei como criar um back-end GraphQL totalmente funcional usando apenas uma imagem Docker e um arquivo de configuração. Tudo isso pode ser encontrado no site do Azure . Por enquanto, vamos falar sobre como automatizar as implantações criadas para nossa hospedagem e nossas atualizações do lado do servidor!
O objetivo de todo esse projeto é criar um back-end para meu futuro arquivo de conteúdo a ser hospedado em meu site . No entanto, sempre que atualizo o back-end ou altero o esquema GraphQL, tenho que fazer uma implantação de serviço completo novamente.
, push Azure. . , , GitHub Azure. , GitHub , ?
GitHub, , Travis Circle, . , .
: + backend-:
, , : docker-compose.yml mongoke.yml, GraphQL.
, , «» — !
GitHub , , , . ? , :
- push
- Azure main service, , Azure/login
- Azure/cli, .
:
- GitHub , , URL- YAML- Mongoke
- URI MongoDB,
-, : , , URL- MongoDB . «» «». , « » . URI MongoDB, MONGODB_URI.
Azure
GitHub Azure, Service Principal. .
Azure CLI. az login, :
az ad sp create-for-rbac --name <SP-name> --role contributor --scopes /subscriptions/<subscriptionID>/resourceGroups/<resourcegroupname> --sdk-auth
ID , az account list : isDefault true. , , : , .
: , , Resource Group. « -», - .
JSON :
{
"clientId": "xxxxxxx",
"clientSecret": "xxxxxxxx",
"subscriptionId": "xxxxxxxx",
...
}
GitHub AZURE_CREDENTIALS:
:
, «» «» « »:
, :
, GitHub Actions — , YAML- /.Github/workflows. , . publish-prod.yml:
:
— GitHub, :
, . , push , , , . , , intellisense:
, . . the official documentation
, , , . env:
, . , . , . , :
Ubuntu, : in the documentation. . — , . , !
, Azure ! Azure/ :
. , :
. , AZURE_CREDENTIALS. , , : $ {{secrets.AZURE_CREDENTIALS}}
.
:
, « », — Azure. run, , . :
, MONGOKE_CONFIG_URL. , SHA- , . , . « URL-».
Workflow Command, GitHub Actions, ::. set-env, . : ::set-env name=<name>::<value>
, :
, ${{env.MONGOKE_CONFIG_URL}} ?v=
native environment variable, GITHUB_SHA. :
, , . MONGOKE_CONFIG_URL, MONGOKE_URL:
:
« » :
«»:
, . , , :
Azure , :
, , URL- :
7 Azure , , , , !
GitHub Actions !
!
. - , dev.to