Skip to content

Commit

Permalink
ci: Reuse docker cache
Browse files Browse the repository at this point in the history
  • Loading branch information
j3soon committed Dec 13, 2024
1 parent 0bba42e commit 86b4936
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 30 deletions.
51 changes: 34 additions & 17 deletions .github/workflows/build-gazebo-world-ws.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,38 @@
name: Build Docker Image for gazebo-world-ws

on:
push:
branches:
- "main"
tags:
- v*
paths:
- .github/workflows/build-gazebo-world-ws.yaml
- gazebo_world_ws/docker/Dockerfile
- gazebo_world_ws/docker/.dockerignore
- gazebo_world_ws/docker/.bashrc
workflow_run:
workflows: [Build Docker Image for template-ws]
types:
- completed

jobs:
docker:
paths-filter:
if: github.repository == 'j3soon/ros2-essentials'
runs-on: ubuntu-latest
outputs:
results: ${{ steps.filter.outputs.results }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
results:
- .github/workflows/build-gazebo-world-ws.yaml
- gazebo_world_ws/docker/Dockerfile
- gazebo_world_ws/docker/.dockerignore
- gazebo_world_ws/docker/.bashrc
- name: Changes matched
if: steps.filter.outputs.results == 'true'
run: echo "Changes matched, will build image"
- name: Changes didn't match
if: steps.filter.outputs.results != 'true'
run: echo "Changes didn't match, will NOT build image"
docker:
needs: paths-filter
if: ${{ needs.paths-filter.outputs.results == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Maximize build space
uses: easimon/maximize-build-space@master
Expand Down Expand Up @@ -57,9 +74,9 @@ jobs:
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: gazebo_world_ws/docker
push: true
tags: ${{ steps.meta.outputs.tags }}
# - name: Build and push
# uses: docker/build-push-action@v4
# with:
# context: gazebo_world_ws/docker
# push: true
# tags: ${{ steps.meta.outputs.tags }}
45 changes: 32 additions & 13 deletions .github/workflows/build-template-ws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,37 @@ on:
push:
branches:
- "main"
- "ci/reuse-docker-cache"
tags:
- v*
paths:
- .github/workflows/build-template-ws.yaml
- template_ws/docker/Dockerfile
- template_ws/docker/.dockerignore
- template_ws/docker/.bashrc

jobs:
docker:
paths-filter:
if: github.repository == 'j3soon/ros2-essentials'
runs-on: ubuntu-latest
outputs:
results: ${{ steps.filter.outputs.results }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
results:
- .github/workflows/build-template-ws.yaml
- template_ws/docker/Dockerfile
- template_ws/docker/.dockerignore
- template_ws/docker/.bashrc
- name: Changes matched
if: steps.filter.outputs.results == 'true'
run: echo "Changes matched, will build image"
- name: Changes didn't match
if: steps.filter.outputs.results != 'true'
run: echo "Changes didn't match, will NOT build image"
docker:
needs: paths-filter
if: ${{ needs.paths-filter.outputs.results == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Maximize build space
uses: easimon/maximize-build-space@master
Expand Down Expand Up @@ -61,10 +80,10 @@ jobs:
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: template_ws/docker
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
# - name: Build and push
# uses: docker/build-push-action@v4
# with:
# context: template_ws/docker
# platforms: linux/amd64,linux/arm64
# push: true
# tags: ${{ steps.meta.outputs.tags }}

0 comments on commit 86b4936

Please sign in to comment.