@@ -23,104 +23,36 @@ env:
2323 SERVICE : catalog-api
2424 IMAGE : catalog.api
2525 DOTNET_VERSION : 5.0.x
26+ PROJECT_PATH : Services/Catalog/Catalog.API
27+ TESTS_PATH : Services/Catalog/Catalog.UnitTests
2628
2729jobs :
2830
2931 BuildContainersForPR_Linux :
3032 runs-on : ubuntu-latest
3133 if : ${{ github.event_name == 'pull_request' }}
3234 steps :
33- - name : ' Checkout Github Action'
34- uses : actions/checkout@master
35-
36- - name : Setup dotnet
37- uses : actions/setup-dotnet@v1
35+ - name : Checkout code
36+ uses : actions/checkout@v2
37+ - uses : ./.github/workflows/composite/build-test
3838 with :
39- dotnet-version : ${{ env.DOTNET_VERSION }}
40-
41- - name : Build and run unit tests
42- run : |
43- cd src
44- dotnet restore "eShopOnContainers-ServicesAndWebApps.sln"
45- cd Services/Catalog/Catalog.API
46- dotnet build --no-restore
47- cd -
48- cd Services/Catalog/Catalog.UnitTests
49- dotnet build --no-restore
50- dotnet test --no-build -v=normal
51-
52- - name : Compose build ${{ env.SERVICE }}
53- run : sudo -E docker-compose build ${{ env.SERVICE }}
54- working-directory : ./src
55- shell : bash
56- env :
57- TAG : ${{ env.BRANCH }}
58- REGISTRY : ${{ secrets.REGISTRY_ENDPOINT }}
39+ service : ${{ env.SERVICE }}
40+ registry_endpoint : ${{ secrets.REGISTRY_ENDPOINT }}
41+ dotnet_version : ${{ env.DOTNET_VERSION }}
42+ project_path : ${{ env.PROJECT_PATH }}
43+ tests_path : ${{ env.TESTS_PATH }}
5944
6045 BuildLinux :
6146 runs-on : ubuntu-latest
6247 if : ${{ github.event_name != 'pull_request' }}
6348 steps :
64- - name : ' Checkout Github Action'
65- uses : actions/checkout@master
66-
67- - name : Setup dotnet
68- uses : actions/setup-dotnet@v1
49+ - name : Checkout code
50+ uses : actions/checkout@v2
51+ - uses : ./.github/workflows/composite/build-push
6952 with :
70- dotnet-version : ${{ env.DOTNET_VERSION }}
71-
72- - name : Build and run unit tests
73- run : |
74- cd src
75- dotnet restore "eShopOnContainers-ServicesAndWebApps.sln"
76- cd Services/Catalog/Catalog.API
77- dotnet build --no-restore
78- cd -
79- cd Services/Catalog/Catalog.UnitTests
80- dotnet build --no-restore
81- dotnet test --no-build -v=normal
82-
83- - name : Enable experimental features for the Docker daemon and CLI
84- run : |
85- echo $'{\n "experimental": true\n}' | sudo tee /etc/docker/daemon.json
86- mkdir -p ~/.docker
87- echo $'{\n "experimental": "enabled"\n}' | sudo tee ~/.docker/config.json
88- sudo service docker restart
89- docker version -f '{{.Client.Experimental}}'
90- docker version -f '{{.Server.Experimental}}'
91-
92- - name : Login to Container Registry
93- uses : docker/login-action@v1
94- with :
95- registry : ${{ secrets.REGISTRY_HOST }}
96- username : ${{ secrets.USERNAME }}
97- password : ${{ secrets.PASSWORD }}
98-
99- - name : Set branch name as env variable
100- run : |
101- currentbranch=$(echo ${GITHUB_REF##*/})
102- echo "running on $currentbranch"
103- echo "BRANCH=$currentbranch" >> $GITHUB_ENV
104- shell : bash
105-
106- - name : Compose build ${{ env.SERVICE }}
107- run : sudo -E docker-compose build ${{ env.SERVICE }}
108- working-directory : ./src
109- shell : bash
110- env :
111- TAG : ${{ env.BRANCH }}
112- REGISTRY : ${{ secrets.REGISTRY_ENDPOINT }}
113-
114- - name : Compose push ${{ env.SERVICE }}
115- run : sudo -E docker-compose push ${{ env.SERVICE }}
116- working-directory : ./src
117- shell : bash
118- env :
119- TAG : ${{ env.BRANCH }}
120- REGISTRY : ${{ secrets.REGISTRY_ENDPOINT }}
121-
122- - name : Create multiarch manifest
123- run : |
124- docker --config ~/.docker manifest create ${{ secrets.REGISTRY_ENDPOINT }}/${{ env.IMAGE }}:${{ env.BRANCH }} ${{ secrets.REGISTRY_ENDPOINT }}/${{ env.IMAGE }}:linux-${{ env.BRANCH }}
125- docker --config ~/.docker manifest push ${{ secrets.REGISTRY_ENDPOINT }}/${{ env.IMAGE }}:${{ env.BRANCH }}
126- shell : bash
53+ service : ${{ env.SERVICE }}
54+ registry_host : ${{ secrets.REGISTRY_HOST }}
55+ registry_endpoint : ${{ secrets.REGISTRY_ENDPOINT }}
56+ image_name : ${{ env.IMAGE }}
57+ registry_username : ${{ secrets.USERNAME }}
58+ registry_password : ${{ secrets.PASSWORD }}
0 commit comments