Skip to content

docker_build_push_acr #126

docker_build_push_acr

docker_build_push_acr #126

Workflow file for this run

name: docker_build_push_acr
on:
push:
branches: [ "main" ]
workflow_dispatch:
jobs:
docker_build_push_acr:
name: 'Docker Build and Push to ACR'
runs-on: ubuntu-latest
environment: production
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v4
# Run unit tests
- name: Unit Tests
run: dotnet test WeatherForecast.Test/WeatherForecast.Test.csproj --logger "console;verbosity=detailed"
# Compose Docker file
- name: Compose Docker file and test container running
id: run-test-cases
run: |
docker-compose -f "docker-compose.yml" up -d
# Netstat
- name: Netstat
run: |
netstat -tulpn
# Docker ps
- name: Docker ps
run: |
docker ps
# Test Container Running
- name: Test container running
run: |
sleep 10s
curl -v http://0.0.0.0:8080/api/v1/weather-forecast/5-day
# Install the newman command line utility
- name: Install newman
run: |
npm install -g newman
# Run newman postman collection tests
- name: run postman collection tests on newman
run: |
newman run ./PostmanCollections/weather-forecast-api.json -e ./PostmanCollections/weather-forecast-api-env.json
# Azure Registary Docker login
- name: 'Azure Docker Login'
uses: azure/docker-login@v1
with:
login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
# Push Docker container to Azure Container Registary
- name: Build the frontend image and push it to ACR
uses: docker/build-push-action@v5
with:
push: true
tags: ${{ secrets.REGISTRY_LOGIN_SERVER }}/weatherforecastapidemo:latest
context: ./WeatherForecast.Api
file: WeatherForecast.Api/Dockerfile
# Stop Docker containers
- name: Stop containers
if: always()
run: docker-compose -f "docker-compose.yml" down