-
Notifications
You must be signed in to change notification settings - Fork 170
148 lines (146 loc) · 4.94 KB
/
trigger_nightly.yaml
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
---
name: Update osrf/ros2:nightly
on:
schedule:
# 7am UTC, 12am PDT
- cron: '0 7 * * *'
push:
branches:
- master
paths:
- '.github/workflows/trigger_nightly.yaml'
- "ros2/nightly/**"
jobs:
check_files:
name: Check Files
runs-on: ubuntu-latest
outputs:
trigger: ${{ steps.check.outputs.trigger }}
no_cache: ${{ steps.check.outputs.no_cache }}
steps:
- name: "Check push event"
id: check
if: github.event_name == 'push'
run: |
echo "trigger=true" >> $GITHUB_OUTPUT
echo "no_cache=false" >> $GITHUB_OUTPUT
check_image:
name: Check Image
if: github.event_name == 'schedule'
needs: check_files
runs-on: ubuntu-latest
outputs:
trigger: ${{ steps.check.outputs.trigger }}
no_cache: ${{ steps.check.outputs.no_cache }}
container:
image: osrf/ros2:nightly
steps:
- name: "Check apt updates"
id: check
env:
SOURCELIST: sources.list.d/ros2-testing.list
run: |
apt-get update \
-o Dir::Etc::sourcelist="${SOURCELIST}"
apt-get --simulate upgrade \
-o Dir::Etc::sourcelist="${SOURCELIST}" \
> upgrade.log
cat upgrade.log
cat upgrade.log \
| grep "^0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.$" \
&& echo "no_cache=false" >> $GITHUB_OUTPUT \
|| echo "no_cache=true" >> $GITHUB_OUTPUT
echo "trigger=true" >> $GITHUB_OUTPUT
rebuild_image:
name: Rebuild Image
if: always()
needs:
- check_files
- check_image
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set build config
id: config
run: |
timestamp=$(date --utc +%Y%m%d%H%M%S)
echo "timestamp=${timestamp}" >> $GITHUB_OUTPUT
no_cache=false
if [ "${{needs.check_files.outputs.no_cache}}" == 'true' ] || \
[ "${{needs.check_image.outputs.no_cache}}" == 'true' ]
then
no_cache=true
fi
echo "no_cache=${no_cache}" >> $GITHUB_OUTPUT
trigger=false
if [ "${{needs.check_files.outputs.trigger}}" == 'true' ] || \
[ "${{needs.check_image.outputs.trigger}}" == 'true' ]
then
trigger=true
fi
echo "trigger=${trigger}" >> $GITHUB_OUTPUT
- name: Build and push nightly
if: steps.config.outputs.trigger == 'true'
id: docker_build_nightly
uses: docker/build-push-action@v6
with:
context: ros2/nightly/nightly
pull: true
push: true
no-cache: ${{ steps.config.outputs.no_cache }}
cache-from: type=registry,ref=osrf/ros2:nightly
cache-to: type=inline
build-args: |
TIMESTAMP=${{ steps.config.outputs.timestamp }}
tags: |
osrf/ros2:nightly
# osrf/ros2:nightly-${{ steps.config.outputs.timestamp }}
- name: Image digest
if: steps.config.outputs.trigger == 'true'
run: echo ${{ steps.docker_build_nightly.outputs.digest }}
- name: Build and push nightly-rmw
if: steps.config.outputs.trigger == 'true'
id: docker_build_nightly-rmw
uses: docker/build-push-action@v6
with:
context: ros2/nightly/nightly-rmw
pull: true
push: true
no-cache: false
cache-from: type=registry,ref=osrf/ros2:nightly-rmw
cache-to: type=inline
build-args: |
TIMESTAMP=${{ steps.config.outputs.timestamp }}
tags: |
osrf/ros2:nightly-rmw
# osrf/ros2:nightly-rmw-${{ steps.config.outputs.timestamp }}
- name: Image digest
if: steps.config.outputs.trigger == 'true'
run: echo ${{ steps.docker_build_nightly-rmw.outputs.digest }}
- name: Build and push nightly-rmw-nonfree
if: steps.config.outputs.trigger == 'true'
id: docker_build_nightly-rmw-nonfree
uses: docker/build-push-action@v6
with:
context: ros2/nightly/nightly-rmw-nonfree
pull: true
push: true
no-cache: false
cache-from: type=registry,ref=osrf/ros2:nightly-rmw-nonfree
cache-to: type=inline
build-args: |
TIMESTAMP=${{ steps.config.outputs.timestamp }}
tags: |
osrf/ros2:nightly-rmw-nonfree
# osrf/ros2:nightly-rmw-nonfree-${{ steps.config.outputs.timestamp }}
- name: Image digest
if: steps.config.outputs.trigger == 'true'
run: echo ${{ steps.docker_build_nightly-rmw-nonfree.outputs.digest }}