-
Notifications
You must be signed in to change notification settings - Fork 1.3k
91 lines (74 loc) · 2.79 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
#https://help.github.com/en/actions/language-and-framework-guides/publishing-docker-images#publishing-images-to-github-packages
name: Publish Docker image
on:
push:
branches:
- master
- development
- docker_workflow
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
DOCKERHUB_IMAGE_NAME: mfeurer/auto-sklearn
jobs:
push_to_registry:
name: Push Docker image to GitHub Packages
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/[email protected]
with:
submodules: recursive
- name: Extract branch name
shell: bash
run: |
echo "Working on GITHUB_REF ${GITHUB_REF}"
echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Extract metadata (tags, labels) for Docker Hub
id: meta_dockerhub
uses: docker/metadata-action@v4
with:
images: ${{ env.DOCKERHUB_IMAGE_NAME }}
- name: Push to Docker Hub
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.meta_dockerhub.outputs.tags }}
labels: ${{ steps.meta_dockerhub.outputs.labels }}
- name: Login to Github
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker on Github Packages
id: meta_githubpackages
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Push to GitHub Packages
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.meta_githubpackages.outputs.tags }}
labels: ${{ steps.meta_githubpackages.outputs.labels }}
- name: Pull Docker image from Github Packages
run: docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$BRANCH
env:
BRANCH: ${{ steps.extract_branch.outputs.branch }}
- name: Run image
run: docker run -i -d --name unittester -v $GITHUB_WORKSPACE:/workspace -w /workspace ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$BRANCH
env:
BRANCH: ${{ steps.extract_branch.outputs.branch }}
- name: Auto-Sklearn loaded
run: docker exec -i unittester python3 -c 'import autosklearn; print(f"Auto-sklearn imported from {autosklearn.__file__}")'
- name: Run unit testing
run: docker exec -i unittester python3 -m pytest -v test