Skip to content

Instantly share code, notes, and snippets.

@WasathTheekshana
Last active October 17, 2023 06:09
Show Gist options
  • Save WasathTheekshana/825aaeed6538d37c948f848602057f8e to your computer and use it in GitHub Desktop.
Save WasathTheekshana/825aaeed6538d37c948f848602057f8e to your computer and use it in GitHub Desktop.
Deploy a Docker Container to Azure Container Registry with a GitHub action
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_SERVER }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- run: |
docker build . -t ${{ secrets.REGISTRY_SERVER }}/yourcontainername:latest
docker push ${{ secrets.REGISTRY_SERVER }}/yourcontainername:latest
@WasathTheekshana
Copy link
Author

First add the repo secrets to the GitHub Secrets

AZURE_CREDENTIALS example

{
  "clientId": "xxxx6ddc-xxxx-xxxx-xxx-ef78a99dxxxx",
  "clientSecret": "xxxx79dc-xxxx-xxxx-xxxx-aaaaaec5xxxx",
  "subscriptionId": "xxxx251c-xxxx-xxxx-xxxx-bf99a306xxxx",
  "tenantId": "xxxx88bf-xxxx-xxxx-xxxx-2d7cd011xxxx",
  "activeDirectoryEndpointUrl": "https://login.microsoftonline.com",
  "resourceManagerEndpointUrl": "https://management.azure.com/",
  "activeDirectoryGraphResourceId": "https://graph.windows.net/",
  "sqlManagementEndpointUrl": "https://management.core.windows.net:8443/",
  "galleryEndpointUrl": "https://gallery.azure.com/",
  "managementEndpointUrl": "https://management.core.windows.net/"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment