From 149e589bb125cda6ee889ba8da79b22a02dd464c Mon Sep 17 00:00:00 2001 From: Yutaka Kondo Date: Thu, 4 Jul 2024 13:47:41 +0900 Subject: [PATCH] refactor action Signed-off-by: Yutaka Kondo --- .../actions/docker-build-and-push/action.yaml | 28 +++++++++++++++++++ .../docker-build-and-push-self-hosted.yaml | 23 ++------------- .github/workflows/docker-build-and-push.yaml | 27 ++---------------- 3 files changed, 32 insertions(+), 46 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..e2a8a64ac26 100644 --- a/.github/workflows/docker-build-and-push-self-hosted.yaml +++ b/.github/workflows/docker-build-and-push-self-hosted.yaml @@ -56,9 +56,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 +64,12 @@ 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..cdf7f1e908b 100644 --- a/.github/workflows/docker-build-and-push.yaml +++ b/.github/workflows/docker-build-and-push.yaml @@ -51,39 +51,16 @@ 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: token: ${{ secrets.GITHUB_TOKEN }} - - 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 }}