Update osrf/ros2:devel #1847
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Update osrf/ros2:devel | |
on: | |
schedule: | |
# 7am UTC, 12am PDT | |
- cron: '0 7 * * *' | |
push: | |
branches: | |
- master | |
paths: | |
- '.github/workflows/trigger_devel.yaml' | |
- "ros2/source/devel/**" | |
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:devel | |
steps: | |
- name: "Check apt updates" | |
id: check | |
env: | |
SOURCELIST: sources.list.d/ros2-latest.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 "trigger=false" >> $GITHUB_OUTPUT \ | |
|| echo "trigger=true" >> $GITHUB_OUTPUT | |
echo "no_cache=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 | |
if: steps.config.outputs.trigger == 'true' | |
id: docker_build | |
uses: docker/build-push-action@v6 | |
with: | |
context: ros2/source/devel | |
pull: true | |
push: true | |
no-cache: ${{ steps.config.outputs.no_cache }} | |
cache-from: type=registry,ref=osrf/ros2:devel | |
cache-to: type=inline | |
tags: | | |
osrf/ros2:devel | |
# osrf/ros2:devel-${{ steps.config.outputs.timestamp }} | |
- name: Image digest | |
if: steps.config.outputs.trigger == 'true' | |
run: echo ${{ steps.docker_build.outputs.digest }} |