From scratch to container automation in 7 minutes

In an earlier article (in Portuguese), I covered how to create a fully functional GraphQL backend using just a Docker image and a config file. All of this can be found on the Azure site . For now, let's talk about how to automate the deployments created for our hosting and our server side updates!



The goal of this entire project is to create a back end for my future content archive to be hosted on my site . However, whenever I update the back end or change the GraphQL schema, I have to do a full service deployment again.



, push Azure. . , , GitHub Azure. , GitHub , ?



GitHub Actions





GitHub, , Travis Circle, . , .



: + backend-:





, , : docker-compose.yml mongoke.yml, GraphQL.



, , «» — !





GitHub , , , . ? , :



  1. push
  2. Azure main service, , Azure/login
  3. 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




All Articles