From 78f680eeb8bbd588ad2556272b53250b5abe0f19 Mon Sep 17 00:00:00 2001 From: Yutaka Kondo Date: Fri, 5 Jul 2024 16:04:17 +0900 Subject: [PATCH] refactor(ci): refactor `docker-build-and-push` action (#4948) * cache only on no-cuda Signed-off-by: Yutaka Kondo * version up Signed-off-by: Yutaka Kondo * version up Signed-off-by: Yutaka Kondo * rename Signed-off-by: Yutaka Kondo * rename Signed-off-by: Yutaka Kondo * rename to health-check Signed-off-by: Yutaka Kondo * refactor action Signed-off-by: Yutaka Kondo * remove old comment Signed-off-by: Yutaka Kondo * revert free disk Signed-off-by: Yutaka Kondo --------- Signed-off-by: Yutaka Kondo --- .../actions/docker-build-and-push/action.yaml | 28 +++++++++++++++++ .../docker-build-and-push-self-hosted.yaml | 30 ++----------------- .github/workflows/docker-build-and-push.yaml | 30 ++----------------- 3 files changed, 32 insertions(+), 56 deletions(-) diff --git a/.github/actions/docker-build-and-push/action.yaml b/.github/actions/docker-build-and-push/action.yaml index 4e42577f96b..bcd59551fef 100644 --- a/.github/actions/docker-build-and-push/action.yaml +++ b/.github/actions/docker-build-and-push/action.yaml @@ -2,6 +2,12 @@ name: docker-build-and-push description: "" inputs: + name: + description: "" + required: true + platform: + description: "" + required: true bake-target: description: "" required: true @@ -35,6 +41,28 @@ runs: vcs import src < autoware.repos shell: bash + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Restore cache + uses: actions/cache/restore@v4 + with: + path: | + root-ccache + key: cache-${{ inputs.platform }}-${{ inputs.name }}-${{ hashFiles('autoware.repos') }} + restore-keys: | + cache-${{ inputs.platform }}-${{ inputs.name }}- + cache-${{ inputs.platform }}- + + - name: Inject cache into docker + uses: reproducible-containers/buildkit-cache-dance@v3.1.2 + with: + cache-map: | + { + "root-ccache": "/root/.ccache" + } + skip-extraction: true + - name: Set Docker tags id: set-docker-tags run: | diff --git a/.github/workflows/docker-build-and-push-self-hosted.yaml b/.github/workflows/docker-build-and-push-self-hosted.yaml index 3dc81ddda5a..9e675a8519b 100644 --- a/.github/workflows/docker-build-and-push-self-hosted.yaml +++ b/.github/workflows/docker-build-and-push-self-hosted.yaml @@ -1,9 +1,3 @@ -# EVENTS: push, schedule, workflow_dispatch -# workflow_dispatch: Build all. No publish to registry; save as tarball. -# schedule: Build only devel and prebuilt. TAGS: date, latest -# push-branch: Build only devel and prebuilt. TAGS: date, latest -# push-tag: Build all. TAGS: version, date, latest - name: docker-build-and-push-self-hosted on: @@ -56,9 +50,6 @@ jobs: - name: Check out repository uses: actions/checkout@v4 - - name: Setup Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Set git config uses: autowarefoundation/autoware-github-actions/set-git-config@v1 with: @@ -67,28 +58,11 @@ jobs: - name: Free disk space uses: ./.github/actions/free-disk-space - - name: Restore cache - uses: actions/cache/restore@v4 - with: - path: | - root-ccache - key: cache-${{ matrix.platform }}-${{ matrix.name }}-${{ hashFiles('autoware.repos') }} - restore-keys: | - cache-${{ matrix.platform }}-${{ matrix.name }}- - cache-${{ matrix.platform }}- - - - name: Inject cache into docker - uses: reproducible-containers/buildkit-cache-dance@v3.1.2 - with: - cache-map: | - { - "root-ccache": "/root/.ccache" - } - skip-extraction: true - - name: Build 'Autoware' uses: ./.github/actions/docker-build-and-push with: + name: ${{ matrix.name }} + platform: ${{ matrix.platform }} bake-target: autoware build-args: | *.platform=linux/${{ matrix.platform }} diff --git a/.github/workflows/docker-build-and-push.yaml b/.github/workflows/docker-build-and-push.yaml index cdaf99ec58f..728bcbde64d 100644 --- a/.github/workflows/docker-build-and-push.yaml +++ b/.github/workflows/docker-build-and-push.yaml @@ -1,9 +1,3 @@ -# EVENTS: push, schedule, workflow_dispatch -# workflow_dispatch: Build all. No publish to registry; save as tarball. -# schedule: Build only devel and prebuilt. TAGS: date, latest -# push-branch: Build only devel and prebuilt. TAGS: date, latest -# push-tag: Build all. TAGS: version, date, latest - name: docker-build-and-push on: @@ -51,9 +45,6 @@ jobs: - name: Check out repository uses: actions/checkout@v4 - - name: Setup Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Set git config uses: autowarefoundation/autoware-github-actions/set-git-config@v1 with: @@ -62,28 +53,11 @@ jobs: - name: Free disk space uses: ./.github/actions/free-disk-space - - name: Restore cache - uses: actions/cache/restore@v4 - with: - path: | - root-ccache - key: cache-${{ matrix.platform }}-${{ matrix.name }}-${{ hashFiles('autoware.repos') }} - restore-keys: | - cache-${{ matrix.platform }}-${{ matrix.name }}- - cache-${{ matrix.platform }}- - - - name: Inject cache into docker - uses: reproducible-containers/buildkit-cache-dance@v3.1.2 - with: - cache-map: | - { - "root-ccache": "/root/.ccache" - } - skip-extraction: true - - name: Build 'Autoware' uses: ./.github/actions/docker-build-and-push with: + name: ${{ matrix.name }} + platform: ${{ matrix.platform }} bake-target: autoware build-args: | *.platform=linux/${{ matrix.platform }}