mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-16 20:37:35 +08:00
ci: build multi platform images
- ci: build containers on releases only - setup: install all compilers for arch - ci: saves cache to s3 and defaults to gh public cache - docker: try to catch apt registry installs - ci: use qemu for arm64 images
This commit is contained in:
@@ -17,32 +17,19 @@ on:
|
||||
jobs:
|
||||
build:
|
||||
name: Build and Push Container
|
||||
runs-on: [runs-on,runner=8cpu-linux-x64,image=ubuntu24-full-x64,"run-id=${{ github.run_id }}",spot=false]
|
||||
runs-on: [runs-on,"runner=8cpu-linux-x64","image=ubuntu24-full-x64","run-id=${{ github.run_id }}",spot=false,extras=s3-cache]
|
||||
steps:
|
||||
- uses: runs-on/action@v1
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-tags: true
|
||||
submodules: false
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set PX4 Tag
|
||||
id: px4-tag
|
||||
- name: Set PX4 Tag Version
|
||||
id: px4_version
|
||||
run: |
|
||||
echo "tag=$(git describe --tags --match 'v[0-9]*')" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
if: github.event_name != 'pull_request'
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
echo "px4_version=$(git describe --tags --match 'v[0-9]*')" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
@@ -50,52 +37,90 @@ jobs:
|
||||
with:
|
||||
images: |
|
||||
ghcr.io/PX4/px4-dev
|
||||
${{ (github.event_name != 'pull_request') && 'px4io/px4-dev' || '' }}
|
||||
px4io/px4-dev
|
||||
tags: |
|
||||
type=raw,enable=true,value=${{ steps.px4-tag.outputs.tag }},priority=1000
|
||||
type=raw,enable=true,value=${{ steps.px4_version.outputs.px4_version }},priority=1000
|
||||
|
||||
- name: Cache Apt Registry
|
||||
uses: actions/cache@v3
|
||||
id: cache
|
||||
with:
|
||||
path: |
|
||||
var-cache-apt
|
||||
var-lib-apt
|
||||
key: cache-${{ hashFiles('Tools/setup/Dockerfile') }}
|
||||
|
||||
- name: Inject Cache into Docker
|
||||
uses: reproducible-containers/buildkit-cache-dance@v3.1.0
|
||||
with:
|
||||
cache-map: |
|
||||
{
|
||||
"var-cache-apt": "/var/cache/apt",
|
||||
"var-lib-apt": "/var/lib/apt"
|
||||
}
|
||||
skip-extraction: ${{ steps.cache.outputs.cache-hit }}
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/') }}
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/') }}
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Build and load container image
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
with:
|
||||
platforms: linux/amd64,linux/arm64
|
||||
|
||||
- name: Build and Load Container Image
|
||||
uses: docker/build-push-action@v6
|
||||
id: docker
|
||||
with:
|
||||
context: Tools/setup
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
platforms: |
|
||||
linux/amd64
|
||||
load: true
|
||||
platforms: linux/amd64,linux/arm64
|
||||
load: false
|
||||
push: false
|
||||
cache-from: type=s3,blobs_prefix=cache/${{ github.repository }}/,manifests_prefix=cache/${{ github.repository }}/,region=${{ env.RUNS_ON_AWS_REGION }},bucket=${{ env.RUNS_ON_S3_BUCKET_CACHE }}
|
||||
cache-to: type=s3,blobs_prefix=cache/${{ github.repository }}/,manifests_prefix=cache/${{ github.repository }}/,region=${{ env.RUNS_ON_AWS_REGION }},bucket=${{ env.RUNS_ON_S3_BUCKET_CACHE }},mode=max
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
- name: Get Tag Name
|
||||
id: tag_name
|
||||
run: |
|
||||
echo "::set-output name=tag_name::$(echo '${{ fromJSON(steps.docker.outputs.metadata)['image.name'] }}' | sed 's/,.*$//')"
|
||||
# - name: Get Container Image Tag Name
|
||||
# id: image_name
|
||||
# run: |
|
||||
# echo "image_name=$(echo '${{ fromJSON(steps.docker.outputs.metadata)['image.name'] }}' | sed 's/,.*$//')" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: make quick_check
|
||||
uses: addnab/docker-run-action@v3
|
||||
with:
|
||||
image: ${{ steps.tag_name.outputs.tag_name }}
|
||||
options: -v ${{ github.workspace }}:/workspace
|
||||
run: |
|
||||
cd /workspace
|
||||
git config --global --add safe.directory /workspace
|
||||
make px4_sitl_default
|
||||
make px4_fmu-v6x_default
|
||||
# - name: Test Build of PX4 with Container
|
||||
# uses: addnab/docker-run-action@v3
|
||||
# with:
|
||||
# image: ${{ steps.image_name.outputs.image_name }}
|
||||
# options: -v ${{ github.workspace }}:/workspace
|
||||
# run: |
|
||||
# cd /workspace
|
||||
# git config --global --add safe.directory /workspace
|
||||
# make px4_sitl_default
|
||||
# make px4_fmu-v6x_default
|
||||
|
||||
- name: Push container image
|
||||
- name: Push Images to Registry
|
||||
uses: docker/build-push-action@v6
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/') }}
|
||||
with:
|
||||
context: Tools/setup
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
platforms: |
|
||||
linux/amd64
|
||||
provenance: mode=max
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
cache-from: type=s3,blobs_prefix=cache/${{ github.repository }}/,manifests_prefix=cache/${{ github.repository }}/,region=${{ env.RUNS_ON_AWS_REGION }},bucket=${{ env.RUNS_ON_S3_BUCKET_CACHE }}
|
||||
cache-to: type=s3,blobs_prefix=cache/${{ github.repository }}/,manifests_prefix=cache/${{ github.repository }}/,region=${{ env.RUNS_ON_AWS_REGION }},bucket=${{ env.RUNS_ON_S3_BUCKET_CACHE }},mode=max
|
||||
platforms: linux/amd64,linux/arm64
|
||||
load: false
|
||||
push: true
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
Reference in New Issue
Block a user