Skip to content

Commit 1f5e05c

Browse files
authored
Merge pull request #272 from CITCOM-project/automate-dafni
Fix: Small changes to the automate-dafni workflow
2 parents 0cb5492 + e09888a commit 1f5e05c

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

.github/workflows/publish-to-dafni.yaml

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,46 @@ name: Containerise and Upload to DAFNI
22

33
on:
44
workflow_dispatch:
5-
workflow_run:
6-
workflows: ["publish-to-pypi"]
7-
branches: main
8-
types: [completed]
5+
release:
6+
types: [published]
97

108
jobs:
11-
12-
check_publish_to_pypi:
13-
name: Check Publish to PyPI
9+
get_release_version:
10+
name: Get Release Version
1411
runs-on: ubuntu-latest
15-
12+
outputs:
13+
version: ${{ steps.get_release.outputs.version }}
1614
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
15+
- name: Checkout code
16+
uses: actions/checkout@v3
2517

18+
- name: Get release version
19+
id: get_release
20+
run: |
21+
export VERSION=$(curl -sSL https://api.github.com/repos/CITCOM-project/CausalTestingFramework/releases/latest | jq -r '.tag_name' | head -c 2)
22+
echo "::set-output name=version::$VERSION"
2623
2724
build_and_upload:
2825
name: Docker Build
29-
if: ${{ github.event_name == 'workflow_dispatch' || needs.check_publish_to_pypi.outputs.check_publish == 'success' }}
26+
needs: get_release_version
27+
if: ${{ github.event_name == 'release' || github.event_name == 'workflow_dispatch' }}
3028
runs-on: ubuntu-latest
3129
env:
3230
DAFNI_PARENT_ID: ${{ secrets.DAFNI_PARENT_ID }}
3331
DAFNI_USERNAME: ${{ secrets.DAFNI_USERNAME }}
3432
DAFNI_PASSWORD: ${{ secrets.DAFNI_PASSWORD }}
35-
CTF_VERSION: "${{ github.event.release.tag_name | replace('.', '') }}"
33+
VERSION: ${{ needs.get_release_version.outputs.version }}
3634

3735
steps:
3836
- uses: actions/checkout@v3
3937
- uses: actions/setup-python@v3
4038
with:
4139
python-version: 3.9
40+
4241
- name: Build the container
4342
run: |
44-
docker build -t ctf:${CTF_VERSION} -f ./dafni/Dockerfile .
45-
docker save ctf:${CTF_VERSION} | gzip > ctf${CTF_VERSION}.tar.gz
43+
docker build -t ctf:${{ env.VERSION }} -f ./dafni/Dockerfile .
44+
docker save ctf:${{ env.VERSION }} | gzip > ctf-dafni-${{ env.VERSION }}.tar.gz
4645
4746
- name: Install DAFNI-CLI and log in
4847
run: |
@@ -51,5 +50,5 @@ jobs:
5150
5251
- name: Upload to DAFNI
5352
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
53+
dafni upload model ./dafni/model_definition.yaml ctf-dafni-${{ env.VERSION }}.tar.gz --version-message "Causal Testing Framework ${{ env.VERSION }}. Uploaded via Github Actions." --parent-id ${{ env.DAFNI_PARENT_ID }} -y
5554
dafni logout

0 commit comments

Comments
 (0)