-
Notifications
You must be signed in to change notification settings - Fork 5
75 lines (62 loc) · 2.48 KB
/
api-build-shared.yml
File metadata and controls
75 lines (62 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: shared workflow to build an API with dotnet publish
on:
workflow_call:
inputs:
version-prefix:
required: true
type: string
version-suffix:
required: true
type: string
containerimage-name:
required: true
type: string
solution-path:
required: true
type: string
registry:
required: true
type: string
secrets:
REGISTRY_USERNAME:
required: true
REGISTRY_PASSWORD:
required: true
jobs:
build:
runs-on: ubuntu-latest
env:
IMAGE_VERSION: ${{ inputs.version-prefix }}-${{ inputs.version-suffix }}
steps:
- name: Show image version
run: echo ${{ env.IMAGE_VERSION }}
- name: Checkout to the branch
uses: actions/checkout@v3
- name: Run unit tests
run: dotnet test ${{ inputs.solution-path }}
# version prefix taken from project file or Directory.build.props
- name: Create Docker image
run: dotnet publish ${{ inputs.solution-path }} --os linux --arch x64 --version-suffix ${{ inputs.version-suffix }} --configuration Release -p:PublishProfile=DefaultContainer -p:ContainerImageName=${{ inputs.containerimage-name }}
# Use Docker cli for push
- name: Docker login
uses: actions-hub/docker/login@master
env:
DOCKER_REGISTRY_URL: ${{ inputs.registry }}
DOCKER_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
- name: Tag image with Azure Container Registry url and version
uses: actions-hub/docker/cli@master
with:
args: tag ${{ inputs.containerimage-name }}:${{ env.IMAGE_VERSION }} ${{ inputs.registry }}/${{ inputs.containerimage-name }}:${{ env.IMAGE_VERSION }}
- name: Tag image with Azure Container Registry url and latest
uses: actions-hub/docker/cli@master
with:
args: tag ${{ inputs.containerimage-name }}:${{ env.IMAGE_VERSION }} ${{ inputs.registry }}/${{ inputs.containerimage-name }}:latest
- name: Push versioned container image to ACR
uses: actions-hub/docker/cli@master
with:
args: push ${{ inputs.registry }}/${{ inputs.containerimage-name }}:${{ env.IMAGE_VERSION }}
- name: Push latest container image to ACR
uses: actions-hub/docker/cli@master
with:
args: push ${{ inputs.registry }}/${{ inputs.containerimage-name }}:latest