mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-02 05:04:08 +08:00
155 lines
4.3 KiB
YAML
155 lines
4.3 KiB
YAML
# build docker images on:
|
|
# * every pull request
|
|
# * push to master
|
|
# * stable release published
|
|
# * tag name is:
|
|
# - commit sha if pull request
|
|
# - 'latest' if push to master
|
|
# - release name if release
|
|
|
|
# pushes to registry if:
|
|
# * is not a pull request
|
|
# * is master branch
|
|
# * is the result of release
|
|
|
|
# builds all nuttx targets and deploys metadata
|
|
|
|
name: Build docker
|
|
|
|
on:
|
|
release:
|
|
types: [released]
|
|
push:
|
|
branches:
|
|
- 'master'
|
|
pull_request:
|
|
|
|
jobs:
|
|
set_docker_tag:
|
|
name: Set docker tag
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
DOCKER_TAG: "px4io/px4-dev"
|
|
outputs:
|
|
docker_tag: ${{ steps.set-outputs.outputs.docker_tag }}
|
|
|
|
steps:
|
|
- name: Set pull request docker tag
|
|
if: github.event_name == 'pull_request'
|
|
run: echo "DOCKER_TAG=px4io/px4-dev:${{ github.sha }}" >> $GITHUB_ENV
|
|
|
|
- name: Set push docker tag
|
|
if: github.event_name == 'push'
|
|
run: echo "DOCKER_TAG=px4io/px4-dev:latest" >> $GITHUB_ENV
|
|
|
|
- name: Set release docker tag
|
|
if: github.event_name == 'release'
|
|
run: echo "DOCKER_TAG=px4io/px4-dev:${{ github.event.release.name }}" >> $GITHUB_ENV
|
|
|
|
- name: Set docker tag outputs
|
|
id: set-outputs
|
|
run: echo "::set-output name=docker_tag::$DOCKER_TAG"
|
|
|
|
build_docker:
|
|
name: Build Docker image
|
|
runs-on: ubuntu-latest
|
|
needs: set_docker_tag
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Login to Github Registry
|
|
uses: docker/login-action@v1
|
|
if: github.event_name == 'push'
|
|
with:
|
|
registry: ghrc.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Set up image builder
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
- name: Build image
|
|
uses: docker/build-push-action@v2
|
|
id: docker_build
|
|
with:
|
|
file: Tools/setup/Dockerfile
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
tags: ${{ needs.set_docker_tag.outputs.docker_tag }}
|
|
outputs: type=tar,dest=/tmp/px4_docker_image.tar
|
|
|
|
- name: Save container to artifacts
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: px4_docker_image
|
|
path: /tmp/px4_docker_image.tar
|
|
|
|
- name: Push to Github Registry
|
|
uses: docker/build-push-action@v2
|
|
if: github.event_name == 'push'
|
|
|
|
- name: Image Digest
|
|
run: echo ${{ steps.docker_build.outputs.digest }}
|
|
|
|
list_targets:
|
|
name: Generate target list
|
|
runs-on: ubuntu-latest
|
|
needs: build_docker
|
|
outputs:
|
|
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
|
|
|
steps:
|
|
- name: Checkout Code
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Setup Python
|
|
uses: actions/setup-python@v2
|
|
with:
|
|
python-version: 3.9
|
|
|
|
#- name: Install Python packages
|
|
#run: pip install -r Tools/setup/requirements.txt
|
|
#run: pip install kconfiglib
|
|
|
|
- id: set-matrix
|
|
name: Get all nuttx targets
|
|
run: echo "::set-output name=matrix::$(./Tools/generate_board_targets_json.py -a)"
|
|
|
|
build_px4:
|
|
name: Build targets with Docker
|
|
runs-on: ubuntu-latest
|
|
needs: [list_targets, set_docker_tag]
|
|
#strategy:
|
|
#matrix: ${{ fromJson(needs.enumerate_targets.outputs.matrix) }}
|
|
|
|
steps:
|
|
- name: Get container from artifacts
|
|
uses: actions/download-artifact@v2
|
|
with:
|
|
name: px4_docker_image
|
|
path: /tmp
|
|
|
|
- name: Load Docker image
|
|
run: |
|
|
docker import /tmp/px4_docker_image.tar ${{ needs.set_docker_tag.outputs.docker_tag }}
|
|
docker image ls -a
|
|
|
|
- name: Checkout Code
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Build targets
|
|
#run: |
|
|
#docker run --rm -w "${GITHUB_ACTION_PATH}" \
|
|
#--env=LOCAL_USER_ID="$(id -u)" \
|
|
#--volume=/tmp:/tmp:rw \
|
|
#--volume=${GITHUB_ACTION_PATH}:${GITHUB_ACTION_PATH}:rw \
|
|
#px4io/px4-dev:${{ needs.set_docker_tag.outputs.docker_tag }} /bin/bash -c "make ${{ matrix.target }}"
|
|
|
|
run: |
|
|
docker run --rm -w ${{ github.workspace }} \
|
|
--env=LOCAL_USER_ID="$(id -u)" \
|
|
--volume=/tmp:/tmp:rw \
|
|
--volume=${{ github.workspace }}:${{ github.workspace }}:rw \
|
|
${{ needs.set_docker_tag.outputs.docker_tag }} /bin/bash -c "make px4_fmu-v6x"
|