Difference between revisions of "Configure a GitHub Action to create a container instance"
Jump to navigation
Jump to search
(Created page with "* https://learn.microsoft.com/en-us/azure/container-instances/container-instances-github-action {{ACR}}") |
|||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
* https://learn.microsoft.com/en-us/azure/container-instances/container-instances-github-action | * https://learn.microsoft.com/en-us/azure/container-instances/container-instances-github-action | ||
+ | * <code>[[az ad sp create-for-rbac]]</code> ([[Terraform resource: azuread service principal]]) | ||
+ | |||
+ | == Pipeline == | ||
+ | <pre> | ||
+ | on: [push] | ||
+ | name: Linux_Container_Workflow | ||
+ | |||
+ | jobs: | ||
+ | build-and-deploy: | ||
+ | runs-on: ubuntu-latest | ||
+ | steps: | ||
+ | # checkout the repo | ||
+ | - name: 'Checkout GitHub Action' | ||
+ | uses: actions/checkout@main | ||
+ | |||
+ | - name: 'Login via Azure CLI' | ||
+ | uses: azure/login@v1 | ||
+ | with: | ||
+ | creds: ${{ secrets.AZURE_CREDENTIALS }} | ||
+ | |||
+ | - name: 'Build and push image' | ||
+ | uses: azure/docker-login@v1 | ||
+ | with: | ||
+ | login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }} | ||
+ | username: ${{ secrets.REGISTRY_USERNAME }} | ||
+ | password: ${{ secrets.REGISTRY_PASSWORD }} | ||
+ | - run: | | ||
+ | docker build . -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/sampleapp:${{ github.sha }} | ||
+ | docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/sampleapp:${{ github.sha }} | ||
+ | |||
+ | - name: 'Deploy to Azure Container Instances' | ||
+ | uses: 'azure/aci-deploy@v1' | ||
+ | with: | ||
+ | resource-group: ${{ secrets.RESOURCE_GROUP }} | ||
+ | dns-name-label: ${{ secrets.RESOURCE_GROUP }}${{ github.run_number }} | ||
+ | image: ${{ secrets.REGISTRY_LOGIN_SERVER }}/sampleapp:${{ github.sha }} | ||
+ | registry-login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }} | ||
+ | registry-username: ${{ secrets.REGISTRY_USERNAME }} | ||
+ | registry-password: ${{ secrets.REGISTRY_PASSWORD }} | ||
+ | name: aci-sampleapp | ||
+ | location: 'west us' | ||
+ | </pre> | ||
{{ACR}} | {{ACR}} |
Latest revision as of 10:58, 17 July 2024
Pipeline[edit]
on: [push] name: Linux_Container_Workflow jobs: build-and-deploy: runs-on: ubuntu-latest steps: # checkout the repo - name: 'Checkout GitHub Action' uses: actions/checkout@main - name: 'Login via Azure CLI' uses: azure/login@v1 with: creds: ${{ secrets.AZURE_CREDENTIALS }} - name: 'Build and push image' uses: azure/docker-login@v1 with: login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }} username: ${{ secrets.REGISTRY_USERNAME }} password: ${{ secrets.REGISTRY_PASSWORD }} - run: | docker build . -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/sampleapp:${{ github.sha }} docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/sampleapp:${{ github.sha }} - name: 'Deploy to Azure Container Instances' uses: 'azure/aci-deploy@v1' with: resource-group: ${{ secrets.RESOURCE_GROUP }} dns-name-label: ${{ secrets.RESOURCE_GROUP }}${{ github.run_number }} image: ${{ secrets.REGISTRY_LOGIN_SERVER }}/sampleapp:${{ github.sha }} registry-login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }} registry-username: ${{ secrets.REGISTRY_USERNAME }} registry-password: ${{ secrets.REGISTRY_PASSWORD }} name: aci-sampleapp location: 'west us'
Azure Container Registry (ACR), azurerm_container_registry
, azurecr.io
, az acr
Advertising: