-
Notifications
You must be signed in to change notification settings - Fork 4
61 lines (59 loc) · 2.2 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
name: Docker images
on: [push]
jobs:
backend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: azure/docker-login@v1
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Build backend docker image
run: |
component="backend"
ref_short=$(basename ${{ github.ref }})
echo component "$component"
echo ref_short "$ref_short"
# build
cd ./$component
docker build -t "$component:latest" .
# tag and push SHA1
docker tag "$component:latest" "penguinjudge/$component:${{ github.sha }}"
docker push "penguinjudge/$component:${{ github.sha }}"
# tag and push ref name
docker tag "$component:latest" "penguinjudge/$component:$ref_short"
docker push "penguinjudge/$component:$ref_short"
# tag and push latest if this action is running on master
if [ "$ref_short" = "master" ]; then
docker tag "$component:latest" "penguinjudge/$component:latest"
docker push "penguinjudge/$component:latest"
fi
frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: azure/docker-login@v1
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Build frontend docker image
run: |
component="frontend"
ref_short=$(basename ${{ github.ref }})
echo component "$component"
echo ref_short "$ref_short"
# build
cd ./$component
docker build -t "$component:latest" .
# tag and push SHA1
docker tag "$component:latest" "penguinjudge/$component:${{ github.sha }}"
docker push "penguinjudge/$component:${{ github.sha }}"
# tag and push ref name
docker tag "$component:latest" "penguinjudge/$component:$ref_short"
docker push "penguinjudge/$component:$ref_short"
# tag and push latest if this action is running on master
if [ "$ref_short" = "master" ]; then
docker tag "$component:latest" "penguinjudge/$component:latest"
docker push "penguinjudge/$component:latest"
fi