-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (91 loc) · 3.79 KB
/
ci.yml
File metadata and controls
103 lines (91 loc) · 3.79 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Build and push Docker image
on:
push:
jobs:
buildAndPushImage:
name: Build and push Docker image
runs-on: ubuntu-latest
steps:
# Free disk space
# Inspiration
# - https://github.com/easimon/maximize-build-space/blob/master/action.yml
# - https://githubmemory.com/repo/ros-industrial/industrial_ci/issues/648
# - https://github.community/t/bigger-github-hosted-runners-disk-space/17267/11
- name: Maximize build space
run: |
sudo apt-get -qq purge build-essential ghc*
sudo apt-get clean
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
docker system prune -f
- name: Checkout repository
uses: actions/checkout@v2.3.4
# Build Docker image
- id: get-timestamp
name: Get timestamp
run: |
TIMESTAMP=$(date --rfc-3339=seconds | sed 's/ /T/')
echo "::set-output name=timestamp::$TIMESTAMP"
- name: Build Docker image
uses: whoan/docker-build-with-cache-action@v5
with:
dockerfile: Dockerfile
build_extra_args: "--compress=true --label org.opencontainers.image.revision=${{github.sha}} --label org.opencontainers.image.created=${{steps.get-timestamp.outputs.timestamp}}"
registry: ghcr.io
stages_image_name: biosimulators/tutorials-stages
image_name: biosimulators/tutorials-stages
image_tag: ${{github.sha}}
push_image_and_stages: true
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
password: "${{ secrets.DOCKER_REGISTRY_TOKEN }}"
- name: Label Docker image
run: |
docker image tag ghcr.io/biosimulators/tutorials-stages:${{github.sha}} ghcr.io/biosimulators/tutorials:${{github.sha}}
docker image tag ghcr.io/biosimulators/tutorials-stages:${{github.sha}} ghcr.io/biosimulators/tutorials:latest
# Test tutorials
- name: Test tutorials
run: |
cwd=$(pwd)
docker run \
--rm \
--entrypoint bash \
--mount type=bind,source=${cwd},target=/home/Biosimulators_tutorials \
--workdir /home/Biosimulators_tutorials \
--user 0 \
ghcr.io/biosimulators/tutorials:latest \
-c "
pip install -r requirements.tests.txt
/bin/bash /xvfb-startup.sh python -m pytest --forked --verbose --nbmake tutorials/
"
# Get version number
- id: get-version-number
name: Get version number
if: startsWith(github.ref, 'refs/tags/')
env:
TAG: ${{ github.ref }}
run: |
version="${TAG/refs\/tags\//}"
echo "::set-output name=version::$version"
# Create GitHub release
- name: Create GitHub release
if: startsWith(github.ref, 'refs/tags/')
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get-version-number.outputs.version }}
release_name: Release ${{ steps.get-version-number.outputs.version }}
# Push Docker image
- name: Push Docker image
if: startsWith(github.ref, 'refs/tags/')
env:
VERSION: ${{ steps.get-version-number.outputs.version }}
run: |
docker image tag ghcr.io/biosimulators/tutorials:${{github.sha}} ghcr.io/biosimulators/tutorials:${VERSION}
docker login ghcr.io \
--username ${{ secrets.DOCKER_REGISTRY_USERNAME }} \
--password ${{ secrets.DOCKER_REGISTRY_TOKEN }}
docker push ghcr.io/biosimulators/tutorials:${{github.sha}}
docker push ghcr.io/biosimulators/tutorials:latest
docker push ghcr.io/biosimulators/tutorials:${VERSION}