From 4fe27d556a7c0a816866d117d6d6867fc83b8888 Mon Sep 17 00:00:00 2001 From: HubbeKing Date: Sun, 17 Oct 2021 18:58:50 +0300 Subject: [PATCH] Use a build-job matrix so components can be built in parallel --- .github/workflows/main.yml | 42 +++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e05b733..d230cd3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,27 +16,41 @@ permissions: contents: read packages: write +# build components using a job matrix, so they can run in parallel jobs: build: - # The type of runner that the job will run on runs-on: ubuntu-20.04 + env: + TAG: ${GITHUB_SHA::8} + strategy: + fail-fast: true # cancel all in-progress jobs if any matrix job fails + matrix: + component: + - downloader + - restreamer + - backfiller + - thrimshim + - cutter + - sheetsync + - nginx + - postgres + - segment_coverage + - playlist_manager steps: - # Checks out repository under $GITHUB_WORKSPACE, so we can access it - - uses: actions/checkout@v2 - + - name: Check out repo + uses: actions/checkout@v2 + - name: Log into ghcr.io uses: docker/login-action@v1 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - - name: Run build script - run: | - # always push - export PUSH=true - # if this is a push to master and not a PR, also push latest - GITHUB_HEAD_REF is only set for PRs - if [ -z ${GITHUB_HEAD_REF+x} ] && [ "$GITHUB_REF" == "refs/heads/master" ]; then export PUSH=latest; fi - # build and push all components. try to pull and re-use layers from images for all parent commits. - 'CACHE_FROM=$(git rev-list HEAD -n1 --parents | cut -d" " -f 2-) ./build' - + + - name: Build ${{ matrix.component }} + uses: docker/build-push-action@v2.7.0 + with: + context: ./${{ matrix.component }} + file: Dockerfile + tags: ghcr.io/ekimekim/wubloader-${{ matrix.component }}:$TAG,ghcr.io/ekimekim/wubloader-${{ matrix.component }}:latest + push: true