name: kuksa_feeders_docker

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]
    
jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
      with: 
        submodules: recursive
    - name: Docker meta
      id: meta
      uses: docker/metadata-action@v3.5.0
      with:
        # list of Docker images to use as base name for tags
        images: |
          kuksa-gps-feeder
        # generate Docker tags based on the following events/attributes
        tags: |
          type=ref,event=branch
          type=ref,event=pr
          type=semver,pattern={{version}}
          type=semver,pattern={{major}}.{{minor}}
          type=semver,pattern={{major}}
          type=sha
    - name: Set up QEMU
      uses: docker/setup-qemu-action@v1
    - name: Set up Docker Buildx
      uses: docker/setup-buildx-action@v1
    - name: build kuksa gps feeder docker for amd64
      uses: docker/build-push-action@v2
      with:
        platforms: linux/amd64
        context: kuksa_feeders/gps2val
        push: false
        tags: ${{ steps.meta.outputs.tags }}
        labels: ${{ steps.meta.outputs.labels }}
        outputs: type=docker,dest=/tmp/kuksa_gps_feeder_amd64.tar # multi-platform images cannot be exported with the docker export type`
        cache-from: type=gha, scope=${{ github.workflow }}
        cache-to: type=gha, scope=${{ github.workflow }}
    - name: build kuksa gps feeder docker for arm64
      uses: docker/build-push-action@v2
      with:
        platforms: linux/arm64
        context: kuksa_feeders/gps2val
        push: false
        tags: ${{ steps.meta.outputs.tags }}
        labels: ${{ steps.meta.outputs.labels }}
        outputs: type=docker,dest=/tmp/kuksa_gps_feeder_arm64.tar # multi-platform images cannot be exported with the docker export type`
        cache-from: type=gha, scope=${{ github.workflow }}
        cache-to: type=gha, scope=${{ github.workflow }}
    - name: Upload AMD64 artifact 
      uses: actions/upload-artifact@v2
      with:
        name: kuksa_gps_feeder_amd64
        path: /tmp/kuksa_gps_feeder_amd64.tar
    - name: Upload ARM64 artifact 
      uses: actions/upload-artifact@v2
      with:
        name: kuksa_gps_feeder_arm64
        path: /tmp/kuksa_gps_feeder_arm64.tar