-
Notifications
You must be signed in to change notification settings - Fork 4
111 lines (89 loc) · 4.02 KB
/
docker-publish.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: Build and Publish Docker Image
on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
- dev
jobs:
build-model-retriever:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Set multiple environment variables
- name: Set Docker image tag and other variables
run: |
echo "WORKER_NAME=emfos-model-retriever" >> $GITHUB_ENV
echo "BRANCH_NAME=$GITHUB_REF_NAME" >> $GITHUB_ENV
echo "IMAGE_TAG=$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV
echo "LATEST_TAG=latest" >> $GITHUB_ENV
# Print env variables
- name: Print environment variables
run: env
# Construct image name
- name: Construct and output IMAGE_NAME
run: |
IMAGE_NAME="${{ vars.DOCKER_USERNAME }}/${WORKER_NAME}"
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV
# Build the Docker image
- name: Build the Docker image
run: |
docker build . --file docker/Dockerfile --target ${{ env.WORKER_NAME }} --tag ${{ env.IMAGE_NAME }}:${{ env.BRANCH_NAME }}-${{ env.IMAGE_TAG }}
docker tag ${{ env.IMAGE_NAME }}:${{ env.BRANCH_NAME }}-${{ env.IMAGE_TAG }} ${{ env.IMAGE_NAME }}:${{ env.BRANCH_NAME }}-${{ env.LATEST_TAG }}
# Log in to Docker Hub
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ vars.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Push the Docker image to Docker Hub
- name: Push Docker image to Docker Hub with date-based tag
run: docker push ${{ env.IMAGE_NAME }}:${{ env.BRANCH_NAME }}-${{ env.IMAGE_TAG }}
- name: Push Docker image to Docker Hub with "latest" tag
run: docker push ${{ env.IMAGE_NAME }}:${{ env.BRANCH_NAME }}-${{ env.LATEST_TAG }}
- name: Image details
run: |
echo "Image ${{ env.IMAGE_NAME }}:${{ env.BRANCH_NAME }}-${{ env.IMAGE_TAG }}} pushed to Docker Hub"
echo "Image ${{ env.IMAGE_NAME }}:${{ env.BRANCH_NAME }}-${{ env.LATEST_TAG }} pushed to Docker Hub"
build-model-merger:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Set multiple environment variables
- name: Set Docker image tag and other variables
run: |
echo "WORKER_NAME=emfos-model-merger" >> $GITHUB_ENV
echo "BRANCH_NAME=$GITHUB_REF_NAME" >> $GITHUB_ENV
echo "IMAGE_TAG=$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV
echo "LATEST_TAG=latest" >> $GITHUB_ENV
# Print env variables
- name: Print environment variables
run: env
# Construct image name
- name: Construct and output IMAGE_NAME
run: |
IMAGE_NAME="${{ vars.DOCKER_USERNAME }}/${WORKER_NAME}"
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV
# Build the Docker image
- name: Build the Docker image
run: |
docker build . --file docker/Dockerfile --target ${{ env.WORKER_NAME }} --tag ${{ env.IMAGE_NAME }}:${{ env.BRANCH_NAME }}-${{ env.IMAGE_TAG }}
docker tag ${{ env.IMAGE_NAME }}:${{ env.BRANCH_NAME }}-${{ env.IMAGE_TAG }} ${{ env.IMAGE_NAME }}:${{ env.BRANCH_NAME }}-${{ env.LATEST_TAG }}
# Log in to Docker Hub
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ vars.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Push the Docker image to Docker Hub
- name: Push Docker image to Docker Hub with date-based tag
run: docker push ${{ env.IMAGE_NAME }}:${{ env.BRANCH_NAME }}-${{ env.IMAGE_TAG }}
- name: Push Docker image to Docker Hub with "latest" tag
run: docker push ${{ env.IMAGE_NAME }}:${{ env.BRANCH_NAME }}-${{ env.LATEST_TAG }}
- name: Image details
run: |
echo "Image ${{ env.IMAGE_NAME }}:${{ env.BRANCH_NAME }}-${{ env.IMAGE_TAG }}} pushed to Docker Hub"
echo "Image ${{ env.IMAGE_NAME }}:${{ env.BRANCH_NAME }}-${{ env.LATEST_TAG }} pushed to Docker Hub"