name: Build on: pull_request: push: branches: - main jobs: build_and_test: runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ windows-latest, ubuntu-latest, macos-latest ] steps: - name: Get the sources uses: actions/checkout@v2 - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: dotnet-version: 5.0.x - name: Clean run: dotnet clean --configuration Release && dotnet nuget locals all --clear - name: Install dependencies run: dotnet restore - name: Build run: dotnet build --configuration Release --no-restore - name: Test run: dotnet test --no-restore --verbosity normal build_and_push: name: Build & Publish to Docker Hub needs: build_and_test runs-on: ubuntu-latest if: github.event_name == 'push' && !contains(github.event.head_commit.message, '[no ci]') steps: - name: Checkout uses: actions/checkout@v2 with: fetch-depth: 0 - name: Extract Git Tag shell: bash run: | tag=$(git describe --tags --abbrev=0) tag2="${tag:1}" short=$(git rev-parse --short HEAD) final="${tag2/prealpha/$short}" echo "GIT_TAG=${final}" >> $GITHUB_ENV - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - name: Cache Docker layers uses: actions/cache@v2.1.4 with: path: /tmp/.buildx-cache key: ${{ runner.os }}-buildx-${{ github.sha }} restore-keys: | ${{ runner.os }}-buildx- - name: Login to DockerHub uses: docker/login-action@v1 with: username: ${{ secrets.DOCKER_HUB_USERNAME }} password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - name: Build and push base uses: docker/build-push-action@v2 with: context: . file: ./docker/Dockerfile push: true build-args: | INFO_VERSION=${{ env.GIT_TAG }}-docker tags: | jasongdove/ersatztv:develop jasongdove/ersatztv:${{ github.sha }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new - # Temporary fix # https://github.com/docker/build-push-action/issues/252 # https://github.com/moby/buildkit/issues/1896 name: Move cache run: | rm -rf /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache - name: Build and push nvidia uses: docker/build-push-action@v2 with: context: . file: ./docker/nvidia/Dockerfile push: true build-args: | INFO_VERSION=${{ env.GIT_TAG }}-docker-nvidia tags: | jasongdove/ersatztv:develop-nvidia jasongdove/ersatztv:${{ github.sha }}-nvidia cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache,mode=max - name: Build and push vaapi uses: docker/build-push-action@v2 with: context: . file: ./docker/vaapi/Dockerfile push: true build-args: | INFO_VERSION=${{ env.GIT_TAG }}-docker-vaapi tags: | jasongdove/ersatztv:develop-vaapi jasongdove/ersatztv:${{ github.sha }}-vaapi cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache,mode=max