-
Notifications
You must be signed in to change notification settings - Fork 6
87 lines (86 loc) · 3.66 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
name: Docker
on:
pull_request:
push:
branches:
- main
schedule:
# Run every week at 20:00 on Sunday
- cron: "0 20 * * 0"
env:
REGISTRY_IMAGE: ghcr.io/${{ github.repository_owner }}/roscon_delib_ws_2024
RAW_BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
jobs:
build:
name: Build and push docker
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Pull latest image for caching
run: |
docker pull ${{ env.REGISTRY_IMAGE }}:latest
continue-on-error: true
- name: Also pull this branch's image for caching
run: |
export BRANCH_NAME=$(echo ${{ env.RAW_BRANCH_NAME }} | sed 's/\//-/g')
docker pull ${{ env.REGISTRY_IMAGE }}:$BRANCH_NAME
continue-on-error: true
- name: Build Docker image
run: |
docker compose build
- name: Build ROS workspace in container
run: |
docker compose run base bash -c "echo ROS Workspace built"
docker compose down --remove-orphans
- name: Run tests in container
run: |
docker compose up test
- name: Convince tests
run: |
docker compose run test diff -r \
src/dependencies/convince/AS2FM/test/jani_generator/_test_data/ros_example/ \
src/technologies/convince/task_1_solution/
docker compose run test diff -r \
src/dependencies/convince/AS2FM/test/jani_generator/_test_data/ros_example_w_bt/ \
src/technologies/convince/task_2_solution/
docker compose run test bash -c "source /delib_ws/install/setup.bash && pytest /delib_ws/src/dependencies/convince/AS2FM/test"
docker compose down --remove-orphans
- name: Push to gh registry with sha and branch
# Do not push on PRs from forks.
if: ${{ !github.event.pull_request.head.repo.fork }}
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin
# tag with sha and push
docker tag ${{ env.REGISTRY_IMAGE }}:latest ${{ env.REGISTRY_IMAGE }}:${{ github.sha }}
docker push ${{ env.REGISTRY_IMAGE }}:${{ github.sha }}
# tag with branch name and push
export BRANCH_NAME=$(echo ${{ env.RAW_BRANCH_NAME }} | sed 's/\//-/g')
docker tag ${{ env.REGISTRY_IMAGE }}:latest ${{ env.REGISTRY_IMAGE }}:$BRANCH_NAME
docker push ${{ env.REGISTRY_IMAGE }}:$BRANCH_NAME
echo "TAG_NAME=$BRANCH_NAME" >> $GITHUB_ENV
- name: Push to gh registry with latest if this is main
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin
# only from main we actually push to latest
docker push ${{ env.REGISTRY_IMAGE }}:latest
echo "TAG_NAME=latest" >> $GITHUB_ENV
if: github.ref == 'refs/heads/main'
- name: Upload tarball to release # in case we need it for the thumbdrive-option at the workshop
run: |
docker save ${{ env.REGISTRY_IMAGE }}:${{ env.TAG_NAME }} | gzip > ./roscon_delib_ws_2024.tar.gz
- name: Release
# Do not release on PRs from forks.
if: ${{ !github.event.pull_request.head.repo.fork }}
uses: ncipollo/release-action@v1
with:
artifacts: './roscon_delib_ws_2024.tar.gz'
token: ${{ secrets.GITHUB_TOKEN }}
commit: ${{ github.sha }}
allowUpdates: true
name: ${{ env.TAG_NAME }}
tag: ${{ env.TAG_NAME }}
makeLatest: ${{ github.ref == 'refs/heads/main' }}