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

add ci using github actions #9

Merged
merged 1 commit into from
Nov 19, 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
135 changes: 135 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
name: build

on:
push:
branches: [ "develop-sdk10" ]
pull_request:
branches: [ "develop-sdk10" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
prepare_container:
runs-on: self-hosted
outputs:
uid: ${{ steps.uid_step.outputs.user }}
gid: ${{ steps.uid_step.outputs.userid }}
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4

- name: Get user id/group
id: uid_step
run: |
echo "user=$(id -un)" >> "$GITHUB_OUTPUT"
echo "userid=$(id -u)" >> "$GITHUB_OUTPUT"

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-config: /etc/docker/cibuilder.toml

- name: Login to Docker Registry
uses: docker/login-action@v3
with:
registry: ciserver.ci:5000
username: ${{ secrets.CI_CACHE_REGISTRY_LOGIN }}
password: ${{ secrets.CI_CACHE_REGISTRY_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: docker
push: true
tags: ciserver.ci:5000/${{ github.repository_id }}:sdk10
cache-from: type=registry,ref=ciserver.ci:5000/${{ github.repository_id }}:cache
cache-to: type=registry,ref=ciserver.ci:5000/${{ github.repository_id }}:cache,mode=max
build-args: |
user=${{ steps.uid_step.outputs.user }}
userid=${{ steps.uid_step.outputs.userid }}

build_images:
needs: prepare_container
runs-on: self-hosted
timeout-minutes: 1080
container:
image: ciserver.ci:5000/${{ github.repository_id }}:sdk10
credentials:
username: ${{ secrets.CI_CACHE_REGISTRY_LOGIN }}
password: ${{ secrets.CI_CACHE_REGISTRY_PASSWORD }}
options: --user "${{ needs.prepare_container.outputs.uid }}:${{ needs.prepare_container.outputs.gid }}"
outputs:
build_tag: ${{ steps.tag_step.outputs.build_tag }}
steps:
- name: Checkout pull-request version of lx2160a_build
uses: actions/checkout@v4

- name: Get build tag
shell: bash {0}
id: tag_step
run: |
build_tag=$(date +%Y-%m-%d)_$(git rev-parse --short HEAD)
echo "build_tag=$build_tag" >> "$GITHUB_OUTPUT"

- name: Build
shell: bash -x {0}
run: |
for env in spi mmc:0:0 mmc:0:1 mmc:0:2 mmc:1:0 mmc:1:1 mmc:1:2; do UBOOT_ENVIRONMENT=$env BOARD_CONFIG=0 CP_NUM=1 ./runme.sh; done
env BOARD_CONFIG=0 CP_NUM=1 UBOOT_ENVIRONMENT=mmc:1:0 BUILD_ROOTFS=yes ./runme.sh
for env in spi mmc:0:0 mmc:0:1 mmc:0:2 mmc:1:0 mmc:1:1 mmc:1:2; do UBOOT_ENVIRONMENT=$env BOARD_CONFIG=0 CP_NUM=2 ./runme.sh; done
env BOARD_CONFIG=0 CP_NUM=2 UBOOT_ENVIRONMENT=mmc:1:0 BUILD_ROOTFS=yes ./runme.sh
for env in spi mmc:0:0 mmc:0:1 mmc:0:2 mmc:1:0 mmc:1:1 mmc:1:2; do UBOOT_ENVIRONMENT=$env BOARD_CONFIG=0 CP_NUM=3 ./runme.sh; done
env BOARD_CONFIG=0 CP_NUM=3 UBOOT_ENVIRONMENT=mmc:1:0 BUILD_ROOTFS=yes ./runme.sh
for env in spi mmc:0:0 mmc:0:1 mmc:0:2 mmc:1:0 mmc:1:1 mmc:1:2; do UBOOT_ENVIRONMENT=$env BOARD_CONFIG=1 ./runme.sh; done
env BOARD_CONFIG=1 UBOOT_ENVIRONMENT=mmc:1:0 BUILD_ROOTFS=yes ./runme.sh
for env in spi mmc:0:0 mmc:0:1 mmc:0:2 mmc:1:0 mmc:1:1 mmc:1:2; do UBOOT_ENVIRONMENT=$env BOARD_CONFIG=2 ./runme.sh; done
env BOARD_CONFIG=2 UBOOT_ENVIRONMENT=mmc:1:0 BUILD_ROOTFS=yes ./runme.sh
for env in spi mmc:0:0 mmc:0:1 mmc:0:2 mmc:1:0 mmc:1:1 mmc:1:2; do UBOOT_ENVIRONMENT=$env BOARD_CONFIG=3 ./runme.sh; done
env BOARD_CONFIG=3 UBOOT_ENVIRONMENT=mmc:1:0 BUILD_ROOTFS=yes ./runme.sh

- name: Select artifacts for publishing
shell: bash -e {0}
run: |
mkdir -p deploy/u-boot
cp -L -v images/*.bin deploy/u-boot
cp -L -v images/*.img deploy
xz -9 deploy/*.img

- name: Deploy to the local minio storage
uses: yakubique/minio-upload@v1.1.3
with:
endpoint: http://ciserver.ci:9000
insecure: true
access_key: ${{ secrets.CI_CACHE_MINIO_ACCESS }}
secret_key: ${{ secrets.CI_CACHE_MINIO_SECRET }}
bucket: cipublish
source: ./deploy
target: "/${{ github.repository_id }}/${{ steps.tag_step.outputs.build_tag }}"
recursive: true

publish_images:
needs: build_images
runs-on: self-hosted
if: github.ref == 'refs/heads/develop-sdk10' && github.event_name != 'pull_request'
steps:
- name: Download an artifacts from MinIO
uses: yakubique/minio-download@v1.1.1
with:
endpoint: http://ciserver.ci:9000
insecure: true
access_key: ${{ secrets.CI_CACHE_MINIO_ACCESS }}
secret_key: ${{ secrets.CI_CACHE_MINIO_SECRET }}
bucket: cipublish
source: "/${{ github.repository_id }}/${{ needs.build_images.outputs.build_tag }}/"
target: "."
recursive: true

- name: Upload to S3
uses: shallwefootball/upload-s3-action@v1.3.3
with:
aws_key_id: ${{ secrets.IMAGES_S3_ACCESS }}
aws_secret_access_key: ${{ secrets.IMAGES_S3_SECRET }}
aws_bucket: ${{ secrets.IMAGES_S3_BUCKET }}
endpoint: ${{ secrets.IMAGES_S3_HOST }}
source_dir: deploy
destination_dir: CN913x/cn913x_build/sdk10/${{ needs.build_images.outputs.build_tag }}
12 changes: 7 additions & 5 deletions runme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ BUILDROOT_VERSION=2020.02.1
: ${UBUNTU_ROOTFS_SIZE:=500M}

# Check if git user name and git email are configured
if [ -z "`git config user.name`" ] || [ -z "`git config user.email`" ]; then
echo "git is not configured, please run:"
echo "git config --global user.email \"you@example.com\""
echo "git config --global user.name \"Your Name\""
exit -1
GIT_CONF=`git config user.name || true`
if [ "x$GIT_CONF" == "x" ]; then
echo "git is not configured! using fake email and username ..."
export GIT_AUTHOR_NAME="SolidRun cn913x_build Script"
export GIT_AUTHOR_EMAIL="support@solid-run.com"
export GIT_COMMITTER_NAME="${GIT_AUTHOR_NAME}"
export GIT_COMMITTER_EMAIL="${GIT_AUTHOR_EMAIL}"
fi

###############################################################################
Expand Down