Skip to content

Github action workflow update #2 #12

Github action workflow update #2

Github action workflow update #2 #12

Workflow file for this run

name: build-u-boot
env:
IMAGE_BASE: onion/u-boot-builder
S3_BUCKET: repo.onioniot.com
S3_REGION: us-east-1
on:
release:
types: [published]
# push:
# branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build-u-boot:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Compute variables
id: vars
run: |
image_tag="${{env.IMAGE_BASE}}:local"
echo "IMAGE_TAG=${image_tag}" >> "$GITHUB_ENV"
echo "Image Tag: ${image_tag}"
- name: Prepare u-boot tree
run: |
bash build.sh setup_tree
cat u-boot/Makefile | head -n 8
- name: Build docker image
run: |
docker build -t ${{ env.IMAGE_TAG }} .
- name: Build u-boot in container
run: |
cid=$(docker create ${{ env.IMAGE_TAG }} \
/bin/bash -c "bash /u-boot-wrapper/build.sh build_uboot")
docker start --attach "$cid"
mkdir -p out
docker cp "$cid":/u-boot-wrapper/u-boot/output/. ./out/
docker rm "$cid"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: u-boot-binaries
path: out/*
build-image:
needs: build-u-boot
runs-on: ubuntu-latest
if: github.event_name == 'release'
steps:
- uses: actions/checkout@v4
- name: Compute variables
id: vars
run: |
date=$(date +'%Y%m%d')
github_sha_hash=${{ github.sha }}
github_sha_short="${github_sha_hash:0:7}"
image_tag_latest="${{env.IMAGE_BASE}}:latest"
image_tag_detailed="${{env.IMAGE_BASE}}:${date}-${github_sha_short}"
echo "GITHUB_SHA_SHORT=${github_sha_short}" >> "$GITHUB_ENV"
echo "IMAGE_TAG_LATEST=${image_tag_latest}" >> "$GITHUB_ENV"
echo "IMAGE_TAG_DETAILED=${image_tag_detailed}" >> "$GITHUB_ENV"
echo "Image Tag Latest: ${image_tag_latest}"
echo "Image Tag Detailed: ${image_tag_detailed}"
- name: Prepare u-boot tree
run: |
bash build.sh setup_tree
cat u-boot/Makefile | head -n 8
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build multiarch image and push
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.IMAGE_TAG_LATEST }}
${{ env.IMAGE_TAG_DETAILED }}
cache-from: type=registry,ref=onion/u-boot-builder:buildcache
cache-to: type=registry,ref=onion/u-boot-builder:buildcache,mode=max
publish:
needs: build-u-boot
runs-on: ubuntu-latest
if: github.event_name == 'release'
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: u-boot-binaries
path: out
- name: Compute variables
id: vars
shell: bash
run: |
source profile
echo "UBOOT_RELEASE=\"${UBOOT_RELEASE}\"" >> "$GITHUB_ENV"
echo "UBOOT_RELEASE=\"${UBOOT_RELEASE}\""
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.S3_REGION }}
- name: Deploy to S3
run: aws s3 cp ./out/* s3://${{ env.S3_BUCKET }}/omega2/bootloader/${{ env.UBOOT_RELEASE }}/