|
|
- name: ordering-api
-
- on:
- workflow_dispatch:
- push:
- branches:
- - dev
-
- paths:
- - src/BuildingBlocks/**
- - src/Services/Ordering/**
- - .github/workflows/ordering-api.yml
-
- pull_request:
- branches:
- - dev
-
- paths:
- - src/BuildingBlocks/**
- - src/Services/Ordering/**
- - .github/workflows/ordering-api.yml
- env:
- SERVICE: ordering-api
- IMAGE: ordering.api
- DOTNET_VERSION: 5.0.x
-
- jobs:
-
- BuildContainersForPR_Linux:
- runs-on: ubuntu-latest
- if: ${{ github.event_name == 'pull_request' }}
- steps:
- - name: 'Checkout Github Action'
- uses: actions/checkout@master
-
- - name: Setup dotnet
- uses: actions/setup-dotnet@v1
- with:
- dotnet-version: ${{ env.DOTNET_VERSION }}
-
- - name: Build and run unit tests
- run: |
- cd src
- dotnet restore "eShopOnContainers-ServicesAndWebApps.sln"
- cd Services/Ordering/Ordering.API
- dotnet build --no-restore
- cd -
- cd Services/Ordering/Ordering.UnitTests
- dotnet build --no-restore
- dotnet test --no-build -v=normal
-
- - name: Compose build ${{ env.SERVICE }}
- run: sudo -E docker-compose build ${{ env.SERVICE }}
- working-directory: ./src
- shell: bash
- env:
- TAG: ${{ env.BRANCH }}
- REGISTRY: ${{ secrets.REGISTRY_ENDPOINT }}
-
- BuildLinux:
- runs-on: ubuntu-latest
- if: ${{ github.event_name != 'pull_request' }}
- steps:
- - name: 'Checkout Github Action'
- uses: actions/checkout@master
-
- - name: Setup dotnet
- uses: actions/setup-dotnet@v1
- with:
- dotnet-version: ${{ env.DOTNET_VERSION }}
-
- - name: Build and run unit tests
- run: |
- cd src
- dotnet restore "eShopOnContainers-ServicesAndWebApps.sln"
- cd Services/Ordering/Ordering.API
- dotnet build --no-restore
- cd -
- cd Services/Ordering/Ordering.UnitTests
- dotnet build --no-restore
- dotnet test --no-build -v=normal
-
- - name: Enable experimental features for the Docker daemon and CLI
- run: |
- echo $'{\n "experimental": true\n}' | sudo tee /etc/docker/daemon.json
- mkdir -p ~/.docker
- echo $'{\n "experimental": "enabled"\n}' | sudo tee ~/.docker/config.json
- sudo service docker restart
- docker version -f '{{.Client.Experimental}}'
- docker version -f '{{.Server.Experimental}}'
-
- - name: Login to Container Registry
- uses: docker/login-action@v1
- with:
- registry: ghcr.io
- username: ${{ github.repository_owner }}
- password: ${{ secrets.GITHUB_TOKEN }}
-
- - name: Pushing Image to Github Container Registry
- uses: docker/build-push-action@v2
- with:
- context: ./src/Services/Ordering/Ordering.API
- version: latest
- file: Dockerfile
- push: true
- tags: ghcr.io/${{ github.repository }}:latest
|