1+ # This workflow uses actions that are not certified by GitHub.
2+ # They are provided by a third-party and are governed by
3+ # separate terms of service, privacy policy, and support
4+ # documentation.
5+
6+ name : Publish Docker image
7+
8+ on :
9+ push :
10+ # Push to `master` or `development`
11+ branches :
12+ - master
13+ - development
14+ - add_docker-publish
15+ workflow_dispatch :
16+
17+ jobs :
18+ push_to_registries :
19+ name : Push Docker image to multiple registries
20+ runs-on : ubuntu-latest
21+ permissions :
22+ packages : write
23+ contents : read
24+ steps :
25+ - name : Check out the repo
26+ uses : actions/checkout@v2
27+
28+ - name : Extract branch name
29+ shell : bash
30+ run : echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
31+ id : extract_branch
32+
33+ - name : Log in to Docker Hub
34+ uses : docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
35+ with :
36+ username : ${{ secrets.DOCKER_USERNAME }}
37+ password : ${{ secrets.DOCKER_PASSWORD }}
38+
39+ - name : Log in to the Container registry
40+ uses : docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
41+ with :
42+ registry : ghcr.io
43+ username : ${{ github.actor }}
44+ password : ${{ secrets.GITHUB_TOKEN }}
45+
46+ - name : Extract metadata (tags, labels) for Docker
47+ id : meta
48+ uses : docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
49+ with :
50+ images : |
51+ automlorg/autopytorch
52+ ghcr.io/${{ github.repository }}
53+
54+ - name : Build and push Docker images
55+ uses : docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
56+ with :
57+ context : .
58+ push : true
59+ tags : ${{ steps.extract_branch.outputs.branch }}
60+
61+ - name : Docker Login
62+ run : docker login ghcr.io -u $GITHUB_ACTOR -p $GITHUB_TOKEN
63+ env :
64+ GITHUB_TOKEN : ${{secrets.GITHUB_TOKEN}}
65+
66+ - name : Pull Docker image
67+ run : docker pull ghcr.io/$GITHUB_REPOSITORY/autoPyTorch:$BRANCH
68+ env :
69+ BRANCH : ${{ steps.extract_branch.outputs.branch }}
70+
71+ - name : Run image
72+ run : docker run -i -d --name unittester -v $GITHUB_WORKSPACE:/workspace -w /workspace ghcr.io/$GITHUB_REPOSITORY/autoPyTorch:$BRANCH
73+ env :
74+ BRANCH : ${{ steps.extract_branch.outputs.branch }}
75+
76+ - name : Auto-PyTorch loaded
77+ run : docker exec -i unittester python3 -c 'import autoPyTorch; print(f"Auto-PyTorch imported from {autoPyTorch.__file__}")'
78+
79+ - name : Run unit testing
80+ run : docker exec -i unittester python3 -m pytest -v test
0 commit comments