Skip to content

Commit 42ec87d

Browse files
committed
chore: initial project setup with GitHub Actions and Docker support
- Added dependabot configuration for GitHub Actions and Docker. - Created workflows for building Docker images and manifests. - Implemented entrypoint script for building MicroPython ports. - Updated README with usage instructions and examples. - Added license information and ensured compliance with MIT License. Signed-off-by: Chiho Sin <[email protected]>
1 parent a9d13be commit 42ec87d

File tree

10 files changed

+701
-47
lines changed

10 files changed

+701
-47
lines changed

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: daily
7+
- package-ecosystem: docker
8+
directory: /
9+
schedule:
10+
interval: daily

.github/workflows/docker_build.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Build container
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
platform:
7+
description: Docker platform to target
8+
required: true
9+
type: string
10+
runs-on:
11+
description: Runner to use
12+
required: true
13+
type: string
14+
push:
15+
description: Push images to registry
16+
required: false
17+
type: boolean
18+
default: false
19+
port:
20+
description: CircuitPython port to target
21+
required: true
22+
type: string
23+
outputs:
24+
digest:
25+
description: Digest of built image
26+
value: ${{ jobs.docker-build.outputs.digest }}
27+
28+
env:
29+
REGISTRY: ghcr.io
30+
IMAGE_NAME: ${{ github.repository }}
31+
32+
permissions:
33+
contents: read
34+
packages: write
35+
id-token: write
36+
attestations: write
37+
38+
jobs:
39+
docker-build:
40+
name: Build ${{ inputs.platform }}
41+
outputs:
42+
digest: ${{ steps.docker_platform.outputs.digest }}
43+
runs-on: ${{ inputs.runs-on }}
44+
steps:
45+
- uses: actions/checkout@v5
46+
47+
- uses: docker/setup-qemu-action@v3
48+
49+
- uses: docker/setup-buildx-action@v3
50+
51+
- name: Docker login
52+
if: ${{ inputs.push }}
53+
uses: docker/login-action@v3
54+
with:
55+
registry: ${{ env.REGISTRY }}
56+
username: ${{ github.actor }}
57+
password: ${{ secrets.GITHUB_TOKEN }}
58+
59+
- name: Sanitize platform string
60+
id: sanitize_platform
61+
# Replace slashes with underscores
62+
run: echo "cleaned_platform=${{ inputs.platform }}" | sed 's/\//_/g' >> $GITHUB_OUTPUT
63+
64+
- name: Docker tag
65+
id: meta
66+
uses: docker/metadata-action@v5
67+
with:
68+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
69+
tags: |
70+
GHA-main-${{ inputs.port }}-${{ steps.sanitize_platform.outputs.cleaned_platform }}
71+
flavor: latest=false
72+
73+
- name: Set up Docker Buildx
74+
uses: docker/setup-buildx-action@v3
75+
76+
- name: Docker build and push
77+
uses: docker/build-push-action@v6
78+
id: docker_platform
79+
with:
80+
context: .
81+
cache-from: type=registry,ref=${{ steps.meta.outputs.tags }}-buildcache
82+
cache-to: type=registry,ref=${{ steps.meta.outputs.tags }}-buildcache,mode=max
83+
push: ${{ inputs.push }}
84+
tags: ${{ steps.meta.outputs.tags }}
85+
labels: ${{ steps.meta.outputs.labels }}
86+
platforms: ${{ inputs.platform }}
87+
target: ${{ inputs.port }}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Build container manifest
2+
on:
3+
workflow_call:
4+
inputs:
5+
port:
6+
description: CircuitPython port to build
7+
required: true
8+
type: string
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
14+
permissions:
15+
contents: read
16+
packages: write
17+
id-token: write
18+
attestations: write
19+
20+
jobs:
21+
docker-amd64:
22+
uses: ./.github/workflows/docker_build.yml
23+
with:
24+
port: ${{ inputs.port }}
25+
platform: linux/amd64
26+
runs-on: ubuntu-24.04
27+
push: true
28+
secrets: inherit
29+
30+
docker-arm64:
31+
uses: ./.github/workflows/docker_build.yml
32+
with:
33+
port: ${{ inputs.port }}
34+
platform: linux/arm64
35+
runs-on: ubuntu-24.04-arm
36+
push: true
37+
secrets: inherit
38+
39+
docker-manifest:
40+
needs:
41+
- docker-amd64
42+
- docker-arm64
43+
runs-on: ubuntu-24.04
44+
steps:
45+
- uses: actions/checkout@v5
46+
47+
- name: Docker Login GHCR
48+
uses: docker/login-action@v3
49+
with:
50+
registry: ${{ env.REGISTRY }}
51+
username: ${{ github.actor }}
52+
password: ${{ secrets.GITHUB_TOKEN }}
53+
54+
- name: Docker meta
55+
id: meta_docker
56+
uses: docker/metadata-action@v5
57+
with:
58+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
59+
tags: |
60+
main-${{ inputs.port }}
61+
flavor: latest=false
62+
63+
- name: Create Docker manifest
64+
id: manifest_docker
65+
uses: int128/docker-manifest-create-action@v2
66+
with:
67+
tags: |
68+
${{ steps.meta_docker.outputs.tags }}
69+
push: true
70+
sources: |
71+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.docker-amd64.outputs.digest }}
72+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.docker-arm64.outputs.digest }}

.github/workflows/on_pr.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Build PR
2+
on:
3+
pull_request:
4+
5+
permissions:
6+
contents: read
7+
packages: write
8+
id-token: write
9+
attestations: write
10+
11+
jobs:
12+
build:
13+
name: Build Test
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
port:
18+
# - analog
19+
# - atmel-samd
20+
# - broadcom
21+
# - cxd56
22+
- espressif
23+
# - litex
24+
# - mimxrt10xx
25+
- nordic
26+
# - raspberrypi
27+
# - renode
28+
# - silabs
29+
# - stm
30+
# - zephyr-cp
31+
uses: ./.github/workflows/docker_build.yml
32+
with:
33+
port: ${{ matrix.port }}
34+
platform: linux/amd64
35+
runs-on: ubuntu-24.04
36+
push: false
37+
secrets: inherit

.github/workflows/on_push.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Build CI
2+
on:
3+
push:
4+
# build and push anytime commits are pushed/merged
5+
branches:
6+
- main
7+
schedule:
8+
# build and push weekly
9+
- cron: 0 0 * * 5
10+
workflow_dispatch: # allow manual triggering
11+
12+
permissions:
13+
contents: read
14+
packages: write
15+
id-token: write
16+
attestations: write
17+
18+
jobs:
19+
build:
20+
name: Build Docker
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
port:
25+
# - analog
26+
# - atmel-samd
27+
# - broadcom
28+
# - cxd56
29+
- espressif
30+
# - litex
31+
# - mimxrt10xx
32+
- nordic
33+
# - raspberrypi
34+
# - renode
35+
# - silabs
36+
# - stm
37+
# - zephyr-cp
38+
uses: ./.github/workflows/docker_manifest.yml
39+
with:
40+
port: ${{ matrix.port }}
41+
secrets: inherit
42+
43+
clean:
44+
name: Cleanup GitHub Packages
45+
needs: build
46+
runs-on: ubuntu-latest
47+
steps:
48+
- name: Cleanup GitHub packages container
49+
uses: dataaxiom/ghcr-cleanup-action@v1
50+
with:
51+
delete-ghost-images: true
52+
delete-untagged: true
53+
token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)