From 3009a94fc392b4517e05c05cb4c8dc2742b6bcf6 Mon Sep 17 00:00:00 2001 From: Mason Tran Date: Wed, 19 Jun 2024 22:12:01 -0400 Subject: [PATCH] fixup! (wip)[actions] trigger build workflow after docker workflow --- .github/workflows/build.yml | 14 +++++----- .github/workflows/docker.yml | 52 +++++++++++++++++++++++++++++------- docker/Dockerfile | 5 ++++ 3 files changed, 53 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 26dae5e7..bc2a45df 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,20 +29,18 @@ name: Build on: - workflow_run: - workflows: [Publish to DockerHub] - types: [completed] + workflow_call: -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/ot-efr32' && github.run_id) || github.ref }} - cancel-in-progress: true +# concurrency: +# group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/ot-efr32' && github.run_id) || github.ref }} +# cancel-in-progress: true jobs: arm-gcc: name: arm-gcc-${{ matrix.gcc_ver }} runs-on: ubuntu-22.04 container: - image: siliconlabsinc/ot-efr32-dev:${{ github.sha }} + image: ghcr.io/siliconlabsinc/ot-efr32-dev:${{ github.sha }} options: --user 1001 strategy: fail-fast: false @@ -80,7 +78,7 @@ jobs: - name: Build run: | export PATH=${HOME}/.local/${{ matrix.gcc_extract_dir }}/bin:$PATH - script/test + script/build brd4151a - name: Gather SLC generated files if: failure() diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 70728cc3..38ac2ade 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -29,7 +29,7 @@ name: Docker env: - SHA_TAG: siliconlabsinc/ot-efr32-dev:${{ github.sha }} + SHA_TAG: ghcr.io/siliconlabsinc/ot-efr32-dev:${{ github.sha }} LATEST_TAG: siliconlabsinc/ot-efr32-dev:latest DOCKER_IMAGE_ARTIFACT_NAME: ot-efr32-dev-image-${{ github.sha }}-${{ github.event_name}}.tar @@ -70,6 +70,8 @@ jobs: - name: Build and export to Docker context uses: docker/build-push-action@v5 with: + build-args: | + BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') context: . file: docker/Dockerfile load: true @@ -122,15 +124,45 @@ jobs: name: ${{ env.DOCKER_IMAGE_ARTIFACT_NAME }} path: /tmp/${{ env.DOCKER_IMAGE_ARTIFACT_NAME }} - publish: - name: Publish to DockerHub + publish-ghcr: + name: Publish to GitHub Container Registry + runs-on: ubuntu-22.04 + needs: [build] + steps: + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Download Docker image + id: download + uses: actions/download-artifact@v4.1.7 + with: + name: ${{ env.DOCKER_IMAGE_ARTIFACT_NAME }} + path: /tmp + + - name: Load Docker image + run: | + docker load --input ${{ steps.download.outputs.download-path }}/${{ env.DOCKER_IMAGE_ARTIFACT_NAME }} + docker inspect ${{ env.SHA_TAG }} + + - name: Push Docker image + run: | + docker push ${{ env.SHA_TAG }} + + publish-dockerhub: + name: Tag `latest` and publish to DockerHub runs-on: ubuntu-22.04 needs: [build] if: | github.repository == 'SiliconLabs/ot-efr32' && - github.event_name != 'pull_request' + github.event_name != 'pull_request' && + github.ref == 'refs/heads/main' steps: - name: Login to DockerHub + if: github.ref == 'refs/heads/main' uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0 with: username: ${{ secrets.DOCKER_USERNAME }} @@ -146,14 +178,14 @@ jobs: - name: Load Docker image run: | docker load --input ${{ steps.download.outputs.download-path }}/${{ env.DOCKER_IMAGE_ARTIFACT_NAME }} - docker image ls -a - - - name: Push Docker image - run: | - docker push ${{ env.SHA_TAG }} + docker inspect ${{ env.SHA_TAG }} - name: Tag `latest` and push - if: github.ref == 'refs/heads/main' run: | docker tag ${{ env.SHA_TAG }} ${{ env.LATEST_TAG }} docker push ${{ env.LATEST_TAG }} + + trigger_build: + name: Trigger Build Workflow + uses: ./.github/workflows/build.yml + needs: [publish-ghcr] diff --git a/docker/Dockerfile b/docker/Dockerfile index 60bc3da4..9858f8c7 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,6 @@ ARG BASE_IMAGE='ubuntu:22.04' +ARG BUILD_DATE + FROM ${BASE_IMAGE} as base ENV TZ="America/New_York" @@ -26,7 +28,10 @@ RUN ./script/bootstrap python # ============================================================================== +# Label the build date before downloading slc to force slc to always be downloaded during a docker build + FROM base AS ot-efr32-dev +LABEL build_date=${BUILD_DATE} COPY ./script/bootstrap_silabs \ ./script/