Skip to content

Commit f121ee4

Browse files
authored
Fix docker workflow (#1576)
* Debug docker workflow failure * Use new login action * Remove broken arguments * Add new push tag * Use docker/meta action * First push to docker, then to github, update repository names * Add docker/meta workflow for docker push * Disambiguate names * Fix registry for github packages login * extract hard-coded names into variables
1 parent ee0916e commit f121ee4

File tree

1 file changed

+44
-19
lines changed

1 file changed

+44
-19
lines changed

.github/workflows/docker-publish.yml

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ on:
99
- development
1010
- docker_workflow
1111

12+
env:
13+
REGISTRY: ghcr.io
14+
IMAGE_NAME: ${{ github.repository }}
15+
DOCKERHUB_IMAGE_NAME: mfeurer/auto-sklearn
16+
1217
jobs:
1318

1419
push_to_registry:
@@ -23,39 +28,59 @@ jobs:
2328

2429
- name: Extract branch name
2530
shell: bash
26-
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
31+
run: |
32+
echo "Working on GITHUB_REF ${GITHUB_REF}"
33+
echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
2734
id: extract_branch
2835

29-
- name: Push to GitHub Packages
36+
- name: Login to Docker Hub
37+
uses: docker/login-action@v2
38+
with:
39+
username: ${{ secrets.DOCKER_USERNAME }}
40+
password: ${{ secrets.DOCKER_TOKEN }}
41+
42+
- name: Extract metadata (tags, labels) for Docker Hub
43+
id: meta_dockerhub
44+
uses: docker/metadata-action@v4
45+
with:
46+
images: ${{ env.DOCKERHUB_IMAGE_NAME }}
47+
48+
- name: Push to Docker Hub
3049
uses: docker/build-push-action@v3
3150
with:
51+
context: .
52+
push: true
53+
tags: ${{ steps.meta_dockerhub.outputs.tags }}
54+
labels: ${{ steps.meta_dockerhub.outputs.labels }}
55+
56+
- name: Login to Github
57+
uses: docker/login-action@v2
58+
with:
59+
registry: ${{ env.REGISTRY }}
3260
username: ${{ github.actor }}
3361
password: ${{ secrets.GITHUB_TOKEN }}
34-
registry: docker.pkg.github.com
35-
repository: automl/auto-sklearn/auto-sklearn
36-
tag_with_ref: true
37-
tags: ${{ steps.extract_branch.outputs.branch }}
3862

39-
- name: Push to Docker Hub
40-
uses: docker/build-push-action@v3
63+
- name: Extract metadata (tags, labels) for Docker on Github Packages
64+
id: meta_githubpackages
65+
uses: docker/metadata-action@v4
4166
with:
42-
username: ${{ secrets.DOCKER_USERNAME }}
43-
password: ${{ secrets.DOCKER_TOKEN }}
44-
repository: mfeurer/auto-sklearn
45-
tags: ${{ steps.extract_branch.outputs.branch }}
67+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
4668

47-
- name: Docker Login
48-
run: docker login docker.pkg.github.com -u $GITHUB_ACTOR -p $GITHUB_TOKEN
49-
env:
50-
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
69+
- name: Push to GitHub Packages
70+
uses: docker/build-push-action@v3
71+
with:
72+
context: .
73+
push: true
74+
tags: ${{ steps.meta_githubpackages.outputs.tags }}
75+
labels: ${{ steps.meta_githubpackages.outputs.labels }}
5176

52-
- name: Pull Docker image
53-
run: docker pull docker.pkg.github.com/$GITHUB_REPOSITORY/auto-sklearn:$BRANCH
77+
- name: Pull Docker image from Github Packages
78+
run: docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$BRANCH
5479
env:
5580
BRANCH: ${{ steps.extract_branch.outputs.branch }}
5681

5782
- name: Run image
58-
run: docker run -i -d --name unittester -v $GITHUB_WORKSPACE:/workspace -w /workspace docker.pkg.github.com/$GITHUB_REPOSITORY/auto-sklearn:$BRANCH
83+
run: docker run -i -d --name unittester -v $GITHUB_WORKSPACE:/workspace -w /workspace ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$BRANCH
5984
env:
6085
BRANCH: ${{ steps.extract_branch.outputs.branch }}
6186

0 commit comments

Comments
 (0)