From 3f9db2788659959873cc9eab171baeeaf2e72c29 Mon Sep 17 00:00:00 2001 From: Stephanos Ioannidis Date: Wed, 2 Mar 2022 19:02:48 +0900 Subject: [PATCH] Add unified CI workflow This commit adds a new unified CI workflow for building and publishing the Zephyr SDK build Docker image. The new unified CI workflow comes with the following changes: 1. Use single workflow for building and publishing Docker image 2. Use the official Docker actions for building and publishing Docker image 3. Upload Docker image to both DockerHub and GitHub Container Registry (GHCR) such that they are always available from both sources. Signed-off-by: Stephanos Ioannidis --- .github/workflows/ci.yml | 64 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..5cee96a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,64 @@ +name: CI + +on: + push: + branches: [ master ] + tags: [ 'v*' ] + pull_request: + branches: [ master ] + +permissions: + packages: write + +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + name: Build + runs-on: ubuntu-20.04 + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Generate metadata + id: meta + uses: docker/metadata-action@v3 + with: + images: | + docker.io/zephyrprojectrtos/sdk-build + ghcr.io/zephyrproject-rtos/sdk-build + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to DockerHub + if: ${{ github.event_name != 'pull_request' }} + uses: docker/login-action@v1 + with: + registry: docker.io + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Login to GitHub Container Registry + if: ${{ github.event_name != 'pull_request' }} + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + context: . + file: Dockerfile + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}