-
Notifications
You must be signed in to change notification settings - Fork 3
85 lines (72 loc) · 2.71 KB
/
docker-image.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
name: docker-image
on:
push:
tags:
- 'v*'
- 'backend-*'
- 'plugin-*'
workflow_call:
secrets:
DOCKER_PASSWORD:
required: true
DOCKER_USERNAME:
required: true
jobs:
build_docker_image:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Create vars
id: vars
run: |
export github_tag=${{ github.ref_name }}
export is_tag_create=false
export rx_tag='^refs\/tags\/.*'
export rx_version_tag='^v([0-9]+\.){0,2}(\*|[0-9]+)(-rc[0-9]*){0,1}$'
if [[ "${{github.ref}}" =~ $rx_tag ]]; then
export is_tag_create=true
fi
echo "::set-output name=github_tag::$github_tag"
echo "::set-output name=is_tag_create::$is_tag_create"
- name: Extract tag prefix
id: tag_prefix
run: |
if [[ ${{ steps.vars.outputs.github_tag }} == backend-* ]]; then
echo "::set-output name=tag_prefix::backend"
elif [[ ${{ steps.vars.outputs.github_tag }} == plugin-* ]]; then
echo "::set-output name=tag_prefix::plugin"
else
echo "::set-output name=tag_prefix::v"
fi
- name: Show environment
run: |
echo is_tag_create = ${{ steps.vars.outputs.is_tag_create }}
echo github_tag = ${{ steps.vars.outputs.github_tag }}
echo tag_prefix = ${{ steps.tag_prefix.outputs.tag_prefix}}
- name: Login to Docker Hub
if: ${{ steps.vars.outputs.is_tag_create == 'true' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME}}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push all docker
if: ${{ steps.tag_prefix.outputs.tag_prefix == 'v'}}
run: |
make docker-backend TAG=latest
make docker-backend TAG=${{ steps.vars.outputs.github_tag }}
make docker-plugin TAG=latest
make docker-plugin TAG=${{ steps.vars.outputs.github_tag }}
make docker-runner TAG=latest
make docker-runner TAG=${{ steps.vars.outputs.github_tag }}
- name: Build and push docker-backend
if: ${{ steps.tag_prefix.outputs.tag_prefix == 'backend'}}
run: |
make docker-backend TAG=latest
make docker-backend TAG=${{ steps.vars.outputs.github_tag }}
make docker-runner TAG=latest
make docker-runner TAG=${{ steps.vars.outputs.github_tag }}
- name: Build and push docker-plugin
if: ${{ steps.tag_prefix.outputs.tag_prefix == 'plugin'}}
run: |
make docker-plugin TAG=latest
make docker-plugin TAG=${{ steps.vars.outputs.github_tag }}