forked from fastai/docker-containers
-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (68 loc) · 2.29 KB
/
nbdev.yaml
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
name: Build nbdev images
on:
schedule:
- cron: '1 6 * * *'
workflow_dispatch: #allows you to trigger manually
push:
branch:
- master
paths:
- 'nbdev-build/**'
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
build_type: [prod, dev]
steps:
- uses: actions/setup-python@v2
with:
python-version: '3.8'
architecture: 'x64'
- name: Install repo2docker
run: python3 -m pip install jupyter-repo2docker
- name: Copy Repository Contents
uses: actions/checkout@main
with:
repository: 'fastai/nbdev'
- name: get version from settings.ini
id: get_variables
run: |
from configparser import ConfigParser
import os
config = ConfigParser()
config.read('settings.ini')
cfg = config['DEFAULT']
print(f"::set-output name=version::{cfg['version']}")
assert os.getenv('BUILD_TYPE') in ['prod', 'dev'], "BUILD_TYPE must be either 'prod' or 'dev'"
shell: python
env:
BUILD_TYPE: ${{ matrix.build_type }}
- name: DockerHub Login
run: |
echo ${PASSWORD} | docker login -u $USERNAME --password-stdin
env:
USERNAME: ${{ secrets.DOCKER_USERNAME }}
PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
- name: Build Prod Container
if: matrix.build_type == 'prod'
run: |
IMAGE_NAME="fastdotai/nbdev"
echo "current directory: ${PWD}"
echo "::set-env name=IMAGE_NAME::${IMAGE_NAME}"
repo2docker --image-name "${IMAGE_NAME}:latest" --push --no-run --user-id 1000 ${PWD}
- name: Build Dev Container (with editable install)
if: matrix.build_type == 'dev'
run: |
IMAGE_NAME="fastdotai/nbdev-dev"
echo "current directory: ${PWD}"
echo "::set-env name=IMAGE_NAME::${IMAGE_NAME}"
repo2docker --image-name "${IMAGE_NAME}:latest" --editable --push --user-id 1000 ${PWD} echo "dev build completed"
- name: push tags
run: |
docker tag ${IMAGE_NAME}:latest ${IMAGE_NAME}:${VERSION}
docker tag ${IMAGE_NAME}:latest ${IMAGE_NAME}:$(date +%F)
docker push ${IMAGE_NAME}:${VERSION}
docker push ${IMAGE_NAME}:$(date +%F)
env:
VERSION: ${{ steps.get_variables.outputs.version }}