generated from allenai/python-package-template
-
Notifications
You must be signed in to change notification settings - Fork 48
57 lines (49 loc) · 1.58 KB
/
docker.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
name: Docker
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
pull_request:
branches:
- main
paths:
- "Dockerfile"
- ".dockerignore"
- "pyproject.toml"
push:
tags:
- "v*.*.*"
jobs:
build:
name: Build (${{ matrix.build.tag }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
build:
- base_image: ghcr.io/allenai/pytorch:1.12.1-cuda11.3-python3.9
tag: cuda11.3
env:
IMAGE_NAME: ghcr.io/allenai/tango
steps:
- uses: actions/checkout@v3
- name: Build Docker image
run: |
docker build --build-arg BASE_IMAGE=${{ matrix.build.base_image }} -t "${IMAGE_NAME}:${{ matrix.build.tag }}" .
- name: Test Docker image
run: |
docker run --rm "${IMAGE_NAME}:${{ matrix.build.tag }}" info
- name: Log in to ghcr.io
if: github.event_name != 'pull_request'
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push latest to ghcr.io
if: github.event_name != 'pull_request'
run: |
docker push "${IMAGE_NAME}:${{ matrix.build.tag }}"
- name: Push release version to ghcr.io
if: startsWith(github.ref, 'refs/tags/')
run: |
GITHUB_TAG=${GITHUB_REF#refs/tags/}
docker tag "${IMAGE_NAME}:${{ matrix.build.tag }}" "${IMAGE_NAME}:${GITHUB_TAG}-${{ matrix.build.tag }}"
docker push "${IMAGE_NAME}:${GITHUB_TAG}-${{ matrix.build.tag }}"