-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented preliminary Action which builds and pushes our containeri…
…zed application to Azure Container Registry based on the argument "ANIMALS", which is derived from Azure Key Vault.
- Loading branch information
hvalfangst
committed
Jan 14, 2024
1 parent
615023c
commit 86e3580
Showing
2 changed files
with
56 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Azure CI/CD | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
jobs: | ||
build-and-deploy: | ||
runs-on: ubuntu-latest | ||
environment: production | ||
env: | ||
|
||
# Foundation | ||
RESOURCE_GROUP: hvalfangstresourcegroup | ||
LOCATION: West Europe | ||
|
||
# Azure Container Registry | ||
ACR_USERNAME: hvalfangstcontainerregistry | ||
CONTAINER_REGISTRY: hvalfangstcontainerregistry.azurecr.io | ||
IMAGE_NAME: hvalfangst-zoo | ||
|
||
# Azure Key Vault | ||
AZURE_KEYVAULT_NAME: hvalfangstkeyvault | ||
ANIMALS: animals-list | ||
|
||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Run Azure Login with Service Principal | ||
run: | | ||
az login --service-principal --username ${{ secrets.AZURE_CLIENT_ID }} --password ${{ secrets.AZURE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }} | ||
- name: Get Secret from Key Vault | ||
id: get_secret | ||
run: | | ||
echo "value=$(az keyvault secret show --name ${{ env.ANIMALS }} --vault-name ${{ env.AZURE_KEYVAULT_NAME }} --query value -o tsv)" >> $GITHUB_OUTPUT | ||
- name: Login to Azure Container Registry | ||
uses: azure/docker-login@v1 | ||
with: | ||
login-server: ${{ env.CONTAINER_REGISTRY }} | ||
username: ${{ env.ACR_USERNAME }} | ||
password: ${{ secrets.ACR_PASSWORD }} | ||
|
||
- name: Build and push Docker image | ||
run: | | ||
docker build -t ${{ env.CONTAINER_REGISTRY }}/${{ env.IMAGE_NAME }}:latest --build-arg ANIMALS="${{steps.get_secret.outputs.value}}" . | ||
docker push ${{ env.CONTAINER_REGISTRY }}/${{ env.IMAGE_NAME }}:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters