Skip to content

Commit 5b9f113

Browse files
authored
Merge pull request #270 from CITCOM-project/automate-dafni
feature: workflow to automate DAFNI push
2 parents b066de4 + 7dd2111 commit 5b9f113

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Containerise and Upload to DAFNI
2+
3+
on:
4+
workflow_dispatch:
5+
workflow_run:
6+
workflows: ["publish-to-pypi"]
7+
branches: main
8+
types: [completed]
9+
10+
jobs:
11+
12+
check_publish_to_pypi:
13+
name: Check Publish to PyPI
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Check if Publish to PyPI succeeded
18+
id: check_publish
19+
run: |
20+
if [ "${{ github.event.workflow_run.conclusion }}" = "success" ]; then
21+
echo "The Causal Testing Framework has been published to PyPI"
22+
else
23+
echo "The Causal Testing Framework has not been published to PyPI"
24+
fi
25+
26+
27+
build_and_upload:
28+
name: Docker Build
29+
if: ${{ github.event_name == 'workflow_dispatch' || needs.check_publish_to_pypi.outputs.check_publish == 'success' }}
30+
runs-on: ubuntu-latest
31+
env:
32+
DAFNI_PARENT_ID: ${{ secrets.DAFNI_PARENT_ID }}
33+
DAFNI_USERNAME: ${{ secrets.DAFNI_USERNAME }}
34+
DAFNI_PASSWORD: ${{ secrets.DAFNI_PASSWORD }}
35+
CTF_VERSION: "${{ github.event.release.tag_name | replace('.', '') }}"
36+
37+
steps:
38+
- uses: actions/checkout@v3
39+
- uses: actions/setup-python@v3
40+
with:
41+
python-version: 3.9
42+
- name: Build the container
43+
run: |
44+
docker build -t ctf:${CTF_VERSION} -f ./dafni/Dockerfile .
45+
docker save ctf:${CTF_VERSION} | gzip > ctf${CTF_VERSION}.tar.gz
46+
47+
- name: Install DAFNI-CLI and log in
48+
run: |
49+
python -m pip install dafni-cli
50+
dafni login
51+
52+
- name: Upload to DAFNI
53+
run: |
54+
dafni upload model ./dafni/model_definition.yaml ctf${CTF_VERSION}.tar.gz --version-message "Version ${CTF_VERSION}. Uploaded via Github." --parent-id ${DAFNI_PARENT_ID} -y
55+
dafni logout

0 commit comments

Comments
 (0)