Skip to content

Commit

Permalink
feat(docker,ci): push autoware image on "push to main branch" and "…
Browse files Browse the repository at this point in the history
…push tag" events (#4993)

* wip

Signed-off-by: Yutaka Kondo <[email protected]>

* fix date

Signed-off-by: Yutaka Kondo <[email protected]>

* add branches

Signed-off-by: Yutaka Kondo <[email protected]>

* wip

Signed-off-by: Yutaka Kondo <[email protected]>

* Revert "fix date"

This reverts commit 5f3b139.

* add tags

Signed-off-by: Yutaka Kondo <[email protected]>

* build only when file changed

Signed-off-by: Yutaka Kondo <[email protected]>

* update condition

Signed-off-by: Yutaka Kondo <[email protected]>

* fix self-hosted

Signed-off-by: Yutaka Kondo <[email protected]>

---------

Signed-off-by: Yutaka Kondo <[email protected]>
  • Loading branch information
youtalk authored Jul 18, 2024
1 parent d5e9bc1 commit ed46a7a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 51 deletions.
29 changes: 2 additions & 27 deletions .github/actions/docker-build-and-push/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ inputs:
tag-suffix:
description: ""
required: false
allow-push:
description: ""
default: "true"
required: false

runs:
using: composite
Expand Down Expand Up @@ -140,48 +136,27 @@ runs:
suffix=-devel${{ inputs.tag-suffix }}
- name: Docker meta for runtime
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref_type == 'tag') }}
id: meta-runtime
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/${{ inputs.bake-target }}
tags: ${{ steps.set-docker-tags.outputs.tags }}
bake-target: docker-metadata-action-runtime
flavor: |
latest=${{ github.event_name == 'push' && github.ref_type == 'tag' }}
latest=auto
suffix=-runtime${{ inputs.tag-suffix }}
- name: Login to GitHub Container Registry
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}

- name: Build and Push to GitHub Container Registry
if: ${{ github.event_name == 'push' ||
github.event_name == 'schedule' ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.artifacts-destination == 'registry') }}
uses: docker/bake-action@v5
with:
push: ${{ inputs.allow-push == 'true' }}
files: |
docker/docker-bake.hcl
${{ steps.meta-base.outputs.bake-file }}
${{ steps.meta-autoware-core.outputs.bake-file }}
${{ steps.meta-autoware-universe.outputs.bake-file }}
${{ steps.meta-devel.outputs.bake-file }}
${{ steps.meta-runtime.outputs.bake-file }}
provenance: false
set: |
${{ inputs.build-args }}
- name: Build only
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.artifacts-destination == 'tarball' }}
uses: docker/bake-action@v5
with:
push: false
push: true
files: |
docker/docker-bake.hcl
${{ steps.meta-base.outputs.bake-file }}
Expand Down
30 changes: 18 additions & 12 deletions .github/workflows/docker-build-and-push-self-hosted.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,10 @@ name: docker-build-and-push-self-hosted

on:
push:
branches:
- main
tags:
- openadkit-v*.*.*
schedule:
- cron: 0 0 1,15 * *
workflow_dispatch:
inputs:
artifacts-destination:
type: choice
description: Destination for the artifacts
options:
- registry
- tarball
default: tarball

jobs:
load-env:
Expand Down Expand Up @@ -58,7 +49,23 @@ jobs:
- name: Free disk space
uses: ./.github/actions/free-disk-space

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
with:
files: |
*.env
*.repos
.github/actions/docker-build-and-push/action.yaml
.github/workflows/docker-build-and-push*.yaml
ansible-galaxy-requirements.yaml
ansible/**
docker/**
- name: Build 'Autoware'
if: ${{ steps.changed-files.outputs.any_changed == 'true' ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'push' && github.ref_type == 'tag') }}
uses: ./.github/actions/docker-build-and-push
with:
name: ${{ matrix.name }}
Expand All @@ -75,7 +82,6 @@ jobs:
*.cache-to=type=registry,ref=ghcr.io/${{ github.repository }}-buildcache:${{ matrix.name }}-${{ matrix.platform }}-${{ github.ref_name }},mode=max
tag-suffix: ${{ matrix.additional-tag-suffix }}-${{ matrix.platform }}
tag-prefix: ${{ needs.load-env.outputs.rosdistro }}
allow-push: true

- name: Show disk space
run: |
Expand Down
30 changes: 18 additions & 12 deletions .github/workflows/docker-build-and-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,10 @@ name: docker-build-and-push

on:
push:
branches:
- main
tags:
- openadkit-v*.*.*
schedule:
- cron: 0 0 1,15 * *
workflow_dispatch:
inputs:
artifacts-destination:
type: choice
description: Destination for the artifacts
options:
- registry
- tarball
default: tarball

jobs:
load-env:
Expand Down Expand Up @@ -53,7 +44,23 @@ jobs:
- name: Free disk space
uses: ./.github/actions/free-disk-space

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
with:
files: |
*.env
*.repos
.github/actions/docker-build-and-push/action.yaml
.github/workflows/docker-build-and-push*.yaml
ansible-galaxy-requirements.yaml
ansible/**
docker/**
- name: Build 'Autoware'
if: ${{ steps.changed-files.outputs.any_changed == 'true' ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'push' && github.ref_type == 'tag') }}
uses: ./.github/actions/docker-build-and-push
with:
name: ${{ matrix.name }}
Expand All @@ -70,7 +77,6 @@ jobs:
*.cache-to=type=registry,ref=ghcr.io/${{ github.repository }}-buildcache:${{ matrix.name }}-${{ matrix.platform }}-${{ github.ref_name }},mode=max
tag-suffix: ${{ matrix.additional-tag-suffix }}-${{ matrix.platform }}
tag-prefix: ${{ needs.load-env.outputs.rosdistro }}
allow-push: true

- name: Show disk space
run: |
Expand Down

0 comments on commit ed46a7a

Please sign in to comment.