Skip to content

Commit

Permalink
fixup! (wip)[actions] trigger build workflow after docker workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
lmnotran committed Jun 20, 2024
1 parent 82bf8d9 commit b4b10f6
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 17 deletions.
30 changes: 22 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -99,3 +97,19 @@ jobs:
with:
name: build-${{ matrix.gcc_ver }}
path: artifact

- name: Lowercase GitHub repository owner
id: lowercase_owner
if: always()
run: |
echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]'
- name: Delete image
uses: bots-house/[email protected]
if: always()
with:
owner: ${{ steps.lowercase_owner.outputs.stdout }}
name: ot-efr32-dev
# NOTE: using Personal Access Token
token: ${{ secrets.PAT }}
tag: ${{ github.sha }}
60 changes: 51 additions & 9 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ env:
SHA_TAG: 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
REPO_OWNER: ''

on:
push:
Expand Down Expand Up @@ -70,6 +71,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
Expand Down Expand Up @@ -122,15 +125,54 @@ 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/[email protected]
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: Lowercase GitHub repository owner
id: lowercase_owner
run: |
echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]'
- name: Tag Docker image
run: |
docker tag ${{ env.SHA_TAG }} ghcr.io/${{ steps.lowercase_owner.outputs.stdout }}/ot-efr32-dev:${{ github.sha }}
- 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 }}
Expand All @@ -146,14 +188,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]
5 changes: 5 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
ARG BASE_IMAGE='ubuntu:22.04'
ARG BUILD_DATE

FROM ${BASE_IMAGE} as base

ENV TZ="America/New_York"
Expand Down Expand Up @@ -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/
Expand Down

0 comments on commit b4b10f6

Please sign in to comment.