Skip to content

Commit e961d82

Browse files
committed
ci: Use git tags as image tags
1 parent 433f9f6 commit e961d82

File tree

2 files changed

+79
-36
lines changed

2 files changed

+79
-36
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: "Shared buildsteps"
2+
runs:
3+
using: "composite"
4+
steps:
5+
- name: Login to Docker Hub 🔐🐳
6+
uses: docker/login-action@v1
7+
with:
8+
username: ${{ secrets.DOCKERHUB_USER }}
9+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
10+
11+
- name: Set up QEMU 🏗️
12+
uses: docker/setup-qemu-action@v1
13+
with:
14+
platforms: amd64,arm64
15+
16+
- name: Free disk space 🧹
17+
run: |
18+
sudo swapoff -a
19+
sudo rm -f /swapfile
20+
sudo apt clean
21+
docker rmi $(docker image ls -aq)
22+
df -h
23+
24+
- name: Set up Docker Buildx 🏗️
25+
id: buildx
26+
uses: docker/setup-buildx-action@v1
27+
28+
- name: Cache Docker layers 💾
29+
uses: actions/cache@v2
30+
with:
31+
path: /tmp/.buildx-cache
32+
key: ${{ runner.os }}-buildx-${{ github.sha }}
33+
restore-keys: |
34+
${{ runner.os }}-buildx-

.github/workflows/main.yml

Lines changed: 45 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,63 +6,72 @@ name: CI
66
on:
77
# Triggers the workflow on push or pull request events but only for the master branch
88
push:
9-
branches: [ master ]
10-
pull_request:
11-
branches: [ master ]
9+
tags:
10+
- 'v*.*.*'
1211

1312
# Allows you to run this workflow manually from the Actions tab
1413
workflow_dispatch:
1514

1615
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1716
jobs:
1817
# This workflow contains a single job called "build"
19-
build:
18+
build-mlflow:
2019
# The type of runner that the job will run on
2120
runs-on: ubuntu-latest
2221

2322
# Steps represent a sequence of tasks that will be executed as part of the job
2423
steps:
25-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
26-
- uses: actions/checkout@v2
27-
28-
- name: Login to Docker Hub
29-
uses: docker/login-action@v1
24+
- name: Checkout Repo ✅
25+
uses: actions/checkout@v2
26+
27+
- uses: ./.github/actions/shared-build-steps
28+
29+
- name: Docker meta 💬
30+
id: meta
31+
uses: docker/metadata-action@v5
3032
with:
31-
username: ${{ secrets.DOCKERHUB_USER }}
32-
password: ${{ secrets.DOCKERHUB_PASSWORD }}
33+
images: codecentric/from-jupyter-to-production-mlflow
3334

34-
- name: Set up QEMU
35-
uses: docker/setup-qemu-action@v1
35+
- name: Build and push mlflow Docker image 🔨🐳
36+
id: docker_build_mlflow
37+
uses: docker/[email protected]
3638
with:
37-
platforms: amd64,arm64
38-
- name: free disk space
39-
run: |
40-
sudo swapoff -a
41-
sudo rm -f /swapfile
42-
sudo apt clean
43-
docker rmi $(docker image ls -aq)
44-
df -h
39+
context: .
40+
file: ./docker/mlflow/Dockerfile
41+
tags: ${{ steps.meta.outputs.tags }}
42+
push: ${{ github.event_name != 'pull_request' }}
43+
builder: ${{ steps.buildx.outputs.name }}
44+
cache-from: type=local,src=/tmp/.buildx-cache
45+
cache-to: type=local,dest=/tmp/.buildx-cache
46+
platforms: linux/amd64,linux/arm64
4547

46-
- name: Set up Docker Buildx
47-
id: buildx
48-
uses: docker/setup-buildx-action@v1
48+
- name: Image digest
49+
run: echo ${{ steps.docker_build.outputs.digest }}
50+
build-jupyter:
51+
# The type of runner that the job will run on
52+
runs-on: ubuntu-latest
4953

50-
- name: Cache Docker layers
51-
uses: actions/cache@v2
54+
# Steps represent a sequence of tasks that will be executed as part of the job
55+
steps:
56+
- name: Checkout Repo ✅
57+
uses: actions/checkout@v2
58+
59+
- uses: ./.github/actions/shared-build-steps
60+
61+
- name: Docker meta 💬
62+
id: meta
63+
uses: docker/metadata-action@v5
5264
with:
53-
path: /tmp/.buildx-cache
54-
key: ${{ runner.os }}-buildx-${{ github.sha }}
55-
restore-keys: |
56-
${{ runner.os }}-buildx-
57-
58-
- name: Build and push mlflow Docker image
59-
id: docker_build_amd64_mlflow
65+
images: codecentric/from-jupyter-to-production-jupyter
66+
67+
- name: Build and push juypter Docker image 🔨🐳
68+
id: docker_build_mlflow
6069
uses: docker/[email protected]
6170
with:
6271
context: .
63-
file: ./docker/mlflow/Dockerfile
64-
tags: codecentric/from-jupyter-to-production-mlflow:1.0.0
65-
push: true
72+
file: ./docker/jupyter/Dockerfile
73+
tags: ${{ steps.meta.outputs.tags }}
74+
push: ${{ github.event_name != 'pull_request' }}
6675
builder: ${{ steps.buildx.outputs.name }}
6776
cache-from: type=local,src=/tmp/.buildx-cache
6877
cache-to: type=local,dest=/tmp/.buildx-cache

0 commit comments

Comments
 (0)