Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docker,ci): push autoware image on "push to main branch" and "push tag" events #4993

Merged
merged 10 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading