Skip to content

Commit e5ea137

Browse files
authored
Merge pull request #997 from minrk/docker-gha
add image-building to GHA
2 parents d25d3c3 + b064835 commit e5ea137

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

.github/workflows/image.yaml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: docker
2+
3+
on:
4+
push:
5+
branches:
6+
pull_request:
7+
8+
jobs:
9+
docker:
10+
runs-on: ubuntu-20.04
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
15+
- name: Set some variables
16+
id: vars
17+
run: |
18+
short_sha=$(git rev-parse --short HEAD)
19+
image="jupyter/nbviewer:$short_sha"
20+
echo "::set-output name=image::$image"
21+
tags="$image"
22+
if "${{ github.ref_name }}" == "master" ]]; then
23+
tags="jupyter/nbviewer:latest $tags"
24+
fi
25+
echo "::set-output name=tags::$tags"
26+
27+
- name: Check outputs
28+
run: echo ${{ steps.vars.outputs.sha_short }}
29+
30+
- name: Login to docker hub
31+
if: github.ref_name == 'master'
32+
uses: docker/login-action@v1
33+
with:
34+
username: ${{ secrets.DOCKER_USERNAME }}
35+
password: ${{ secrets.DOCKER_TOKEN }}
36+
37+
- name: Build
38+
uses: docker/build-push-action@v2
39+
with:
40+
push: false
41+
load: true
42+
context: .
43+
platforms: linux/amd64
44+
tags: ${{ steps.vars.outputs.tags }}
45+
46+
- name: Test
47+
run: |
48+
docker run --rm -i ${{ steps.vars.outputs.image }} python3 -c "import nbviewer, pycurl, pylibmc"
49+
docker run --rm -i ${{ steps.vars.outputs.image }} python3 -m nbviewer --help-all
50+
51+
- name: Push
52+
if: github.ref_name == 'master'
53+
uses: docker/build-push-action@v2
54+
with:
55+
context: .
56+
platforms: linux/amd64
57+
push: ${{ github.ref_name == 'master' }}
58+
tags: ${{ steps.vars.outputs.tags }}

0 commit comments

Comments
 (0)