-
-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (81 loc) · 2.51 KB
/
deploy-docker.yml
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: deploy-docker
on:
workflow_call:
inputs:
runs-on:
description: 'The operating system to run the job on'
required: true
type: string
registry:
description: 'Registry to push image'
required: true
type: string
project:
description: 'String in ProjectName---DockerfilePath format'
required: true
type: string
build-props-path:
description: 'Path to Directory.Build.props file'
required: false
type: string
default: 'Directory.Build.props'
continious-tag:
description: 'Tag for conrinious docker builds'
required: false
type: string
default: 'latest'
username:
description: 'Username on publishing platform'
required: true
type: string
secrets:
TOKEN:
required: true
jobs:
deploy:
runs-on: ${{inputs.runs-on}}
defaults:
run:
shell: pwsh
env:
image: ''
project: ''
dockerfile: ''
steps:
- uses: actions/checkout@v4
- name: set-project-name-dockerfile
run: |
$project = "${{inputs.project}}".Split("---")[0]
$dockerfile = "${{inputs.project}}".Split("---")[1]
Write-Output "project=$project" >> $env:GITHUB_ENV
Write-Output "dockerfile=$dockerfile" >> $env:GITHUB_ENV
- name: read-version
id: read-version
uses: ./.github/actions/read-version
with:
build-props-path: ${{inputs.build-props-path}}
continious-tag: ${{inputs.continious-tag}}
- name: set-image
run: |
$image = "${{inputs.registry}}/${{inputs.username}}/${{env.project}}"
Write-Output "image=$image" >> $env:GITHUB_ENV
- name: docker-login
uses: docker/login-action@v3
with:
registry: ${{inputs.registry}}
username: ${{inputs.username}}
password: ${{secrets.TOKEN}}
- name: docker-extract-meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{env.image}}
tags: type=raw,value=${{steps.read-version.outputs.docker-tag}}
- name: docker-build-push
uses: docker/build-push-action@v6
with:
context: .
file: ${{env.dockerfile}}
push: ${{github.event_name != 'pull_request'}}
tags: ${{steps.meta.outputs.tags}}
labels: ${{steps.meta.outputs.labels}}