Build Armbian arm64 Docker image #111
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #===================================================================================== | |
| # https://github.com/ophub/amlogic-s9xxx-armbian | |
| # Description: Build and publish Armbian arm64 Docker image | |
| # Instructions: https://github.com/docker/build-push-action | |
| # Build and Push to: https://hub.docker.com/ | |
| #===================================================================================== | |
| name: Build Armbian arm64 Docker image | |
| on: | |
| repository_dispatch: | |
| workflow_dispatch: | |
| inputs: | |
| source_branch: | |
| description: "Select the source branch" | |
| required: false | |
| default: "trixie" | |
| type: choice | |
| options: | |
| - trixie | |
| - bookworm | |
| - resolute | |
| - noble | |
| docker_img: | |
| description: "Set the docker image" | |
| required: false | |
| default: "ophub/armbian" | |
| type: choice | |
| options: | |
| - ophub/armbian | |
| env: | |
| TZ: Etc/UTC | |
| MAKE_DOCKER_SH: compile-kernel/tools/script/docker/build_armbian_docker_image.sh | |
| jobs: | |
| build: | |
| runs-on: ubuntu-24.04-arm | |
| if: ${{ github.event.repository.owner.id == github.event.sender.id }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Download Armbian rootfs file [ ${{ inputs.source_branch }} ] | |
| id: down | |
| if: (!cancelled()) | |
| run: | | |
| # Retrieve the latest Armbian rootfs file from releases | |
| latest_version=$(curl -s \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
| https://api.github.com/repos/${{ github.repository }}/releases?per_page=20 | \ | |
| jq -r --arg RTK "Armbian_${{ inputs.source_branch }}_arm64_" \ | |
| --arg BOARD "rootfs" \ | |
| '[.[] | select(.tag_name | contains($RTK)) | | |
| {tag: .tag_name} + (.assets[] | select(.name | contains($BOARD) and endswith(".tar.gz")) | | |
| {data: .updated_at, url: .url, name: .name})] | | |
| sort_by(.data) | | |
| reverse | | |
| .[0]') | |
| [[ -z "${latest_version}" || "${latest_version}" == "null" ]] && { | |
| echo "Error: Failed to resolve Armbian rootfs download URL." | |
| exit 1 | |
| } | |
| # Extract download URL, filename, and release tag | |
| latest_url="$(echo ${latest_version} | jq -r '.url')" | |
| armbian_filename="$(echo ${latest_version} | jq -r '.name')" | |
| release_tag="$(echo ${latest_version} | jq -r '.tag')" | |
| echo "Matched release tag: ${release_tag}" | |
| echo "build_tag=${release_tag}" >> ${GITHUB_OUTPUT} | |
| # Download asset via GitHub API (binary stream) | |
| echo "Downloading: ${armbian_filename}" | |
| [[ -d "armbian" ]] || mkdir -p armbian | |
| curl -fsSL \ | |
| -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
| -H "Accept: application/octet-stream" \ | |
| "${latest_url}" \ | |
| -o "armbian/${armbian_filename}" | |
| [[ "${?}" -ne "0" ]] && echo "Error: Download failed." && exit 1 | |
| echo "status=success" >> ${GITHUB_OUTPUT} | |
| - name: Build the Docker image | |
| id: make | |
| if: ${{ steps.down.outputs.status == 'success' && !cancelled() }} | |
| run: | | |
| chmod +x ${MAKE_DOCKER_SH} | |
| ${MAKE_DOCKER_SH} ${{ inputs.source_branch }} arm64 | |
| echo "status=success" >> ${GITHUB_OUTPUT} | |
| - name: Upload rebuilt images to Release | |
| uses: ncipollo/release-action@main | |
| if: ${{ steps.make.outputs.status == 'success' && !cancelled() }} | |
| with: | |
| tag: ${{ steps.down.outputs.build_tag }} | |
| artifacts: out/*.tar.gz | |
| allowUpdates: true | |
| removeArtifacts: false | |
| replacesArtifacts: true | |
| makeLatest: true | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| body: | | |
| ### Armbian Image Information | |
| - Default username: `root` | |
| - Default password: `1234` | |
| - Install command: `armbian-install` | |
| - Update command: `armbian-update` | |
| ### Applicable Platform | |
| - 🐧 `arm64` | |
| - 🐋 Docker image: https://hub.docker.com/u/ophub | |
| - name: Login to Docker Hub | |
| id: login | |
| if: ${{ steps.make.outputs.status == 'success' && !cancelled() }} | |
| uses: docker/login-action@v4 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
| - name: Load and push image to Docker Hub | |
| id: push | |
| if: ${{ steps.make.outputs.status == 'success' && !cancelled() }} | |
| run: | | |
| # Load the offline Docker image built by build_armbian_docker_image.sh | |
| offline_image="$(ls out/*.tar.gz 2>/dev/null | head -n 1)" | |
| [[ -z "${offline_image}" ]] && echo "Error: No offline image found." && exit 1 | |
| loaded_image="$(docker load -i "${offline_image}" | grep -oP 'Loaded image: \K.*')" | |
| [[ -z "${loaded_image}" ]] && echo "Error: Failed to load Docker image." && exit 1 | |
| echo "Loaded image: ${loaded_image}" | |
| # Tag for Docker Hub | |
| docker tag "${loaded_image}" "${{ inputs.docker_img }}-${{ inputs.source_branch }}:arm64" | |
| docker tag "${loaded_image}" "${{ inputs.docker_img }}-${{ inputs.source_branch }}:latest" | |
| # Push to Docker Hub | |
| docker push "${{ inputs.docker_img }}-${{ inputs.source_branch }}:arm64" | |
| docker push "${{ inputs.docker_img }}-${{ inputs.source_branch }}:latest" | |
| echo "status=success" >> ${GITHUB_OUTPUT} | |