name: Docker Image CI

on:
  push:
    branches:
      - main
  workflow_dispatch: {}

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Login to Docker Hub
      uses: docker/login-action@v1
      with:
        username: ${{ secrets.DockerHubUsername }}
        password: ${{ secrets.DockerHubPassword }}
    - name: Set up Docker Buildx
      id: buildx
      uses: docker/setup-buildx-action@master
    - name: Build and push
      id: docker_build
      uses: docker/build-push-action@v2
      with:
        context: .
        push: true
        target: production
        tags: |
          neinteractiveliterature/intercode:latest
          neinteractiveliterature/intercode:${{ github.sha }}
        cache-from: type=gha
        cache-to: type=gha,mode=max

name: Docker Image CI

on:
  push:
    branches:
      - main
  workflow_dispatch: {}

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Login to Docker Hub
      uses: docker/login-action@v1
      with:
        username: ${{ secrets.DockerHubUsername }}
        password: ${{ secrets.DockerHubPassword }}
    - name: Set up Docker Buildx
      id: buildx
      uses: docker/setup-buildx-action@master
    - # Temp fix, see below
      name: Cache Docker layers
      uses: actions/cache@v2
      with:
        path: /tmp/.buildx-cache
        key: ${{ runner.os }}-buildx-${{ github.sha }}
        restore-keys: |
          ${{ runner.os }}-buildx-
    - name: Build and push
      id: docker_build
      uses: docker/build-push-action@v2
      with:
        context: .
        push: true
        target: production
        tags: |
          neinteractiveliterature/intercode:latest
          neinteractiveliterature/intercode:${{ github.sha }}
        # TODO: put this back once it gets working again
        # cache-from: type=gha
        # cache-to: type=gha,mode=max
        cache-from: type=local,src=/tmp/.buildx-cache
        cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
    -
      # Temp 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

Switch away from experimental GHA cache until it's not broken
Switch away from experimental GHA cache until it's not broken
