diff --git a/.github/workflows/sdk-ci.yml b/.github/workflows/sdk-ci.yml index 7d31b12..4e20f5f 100644 --- a/.github/workflows/sdk-ci.yml +++ b/.github/workflows/sdk-ci.yml @@ -1,4 +1,5 @@ -name: Raspberry PI Pico Docker SDK CI + +name: Build, test and push Docker image on: push: @@ -14,39 +15,64 @@ env: TEST_TAG: pico_test_sdk jobs: - sdk_container: + build-and-test: runs-on: ubuntu-latest steps: - - name: Checkout + - name: Checkout code uses: actions/checkout@v3 - - name: Set up QEMU + + - name: Set up QEMU (for ARM builds) uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Build SDK + + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ github.actor }} + password: ${{ secrets.DOCKER_HUB_TOKEN }} + + - name: Build Docker image (multi-arch, no push) uses: docker/build-push-action@v6 + id: build with: context: . - load: true + platforms: linux/amd64 + push: false + load: true # Allows testing the image locally tags: ${{ env.TEST_TAG }} - - name: Test SDK + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Run Tests (from built image) run: bash ./test_sdk.sh ${{ env.TEST_TAG }} - - name: Log into Docker Hub + + push-image: + needs: build-and-test + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to DockerHub uses: docker/login-action@v3 with: username: ${{ github.actor }} password: ${{ secrets.DOCKER_HUB_TOKEN }} - - name: Extract SDK metadata - id: meta - uses: docker/metadata-action@v4 - with: - images: lukstep/raspberry-pi-pico-sdk - - name: Push SDK image - if: github.event_name == 'release' && github.event.action == 'published' + + - name: Build and Push Docker image (multi-arch) uses: docker/build-push-action@v6 with: context: . - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} platforms: linux/amd64,linux/arm64 + push: true + tags: lukstep/raspberry-pi-pico-sdk:latest + cache-from: type=gha + cache-to: type=gha,mode=max