-
Notifications
You must be signed in to change notification settings - Fork 7
87 lines (84 loc) · 3.12 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
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
# A single CI script with github workflow.
name: Store docker for tag
on:
push:
tags:
- '*'
# some general variables
env:
CONDA_PY: 310
IMAGE_NAME: nnpdf
jobs:
build:
# setup job
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.10"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v1
- uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python-version }}
- name: Setup conda and install conda-build
shell: bash -l {0}
run: |
conda install -n base conda-libmamba-solver
conda config --set solver libmamba
conda config --append channels conda-forge
conda config --prepend channels https://packages.nnpdf.science/public
conda config --set show_channel_urls true
conda install boa --yes
- name: Build recipe
shell: bash -l {0}
run: |
CONDA_PY=$CONDA_PY conda mambabuild --no-test -q conda-recipe
# install local build
- name: Copying conda channel locally
run: |
cp -r /usr/share/miniconda/envs/test/conda-bld/ .
# create fancy runcards
- name: Build docker image and export environment
run: |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,'); echo "VERSION=$VERSION" >> $GITHUB_ENV
CONDA_ENV_NAME=nnpdfenv-tag-$VERSION
docker build . --build-arg CONDA_ENV_NAME=$CONDA_ENV_NAME --file docker/dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
docker run --rm --entrypoint cat nnpdf /root/$CONDA_ENV_NAME.yml > n3fit/runcards/$CONDA_ENV_NAME.yml
rm -r conda-bld/
# upload to github packages
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push image
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
# Create PR with the docker conda environment
- name: Create Pull Request with docker conda environment
id: cpr
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: add conda environment
committer: GitHub <[email protected]>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
base: master
branch: add-tag-environment
branch-suffix: random
delete-branch: true
title: '[bot] Add conda environment for tag ${{ env.VERSION }}'
body: |
Included conda environment for tag ${{ env.VERSION }}.
Please review and merge.
reviewers: scarrazza
draft: false
- name: Check outputs
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"