|
| 1 | +--- |
| 2 | +name: build-flashers |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - master |
| 8 | + paths: |
| 9 | + - 'flashers/**' |
| 10 | + pull_request: |
| 11 | + branches: |
| 12 | + - '*' |
| 13 | + paths: |
| 14 | + - 'flashers/**' |
| 15 | +jobs: |
| 16 | + build-riotdocker-base: |
| 17 | + name: Build and push images |
| 18 | + runs-on: ubuntu-latest |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: checkout |
| 22 | + uses: actions/checkout@v2 |
| 23 | + |
| 24 | + - name: Set up QEMU |
| 25 | + uses: docker/setup-qemu-action@v1 |
| 26 | + |
| 27 | + - name: Set up Docker Buildx |
| 28 | + uses: docker/setup-buildx-action@v1 |
| 29 | + |
| 30 | + - name: Login to DockerHub |
| 31 | + uses: docker/login-action@v1 |
| 32 | + with: |
| 33 | + username: ${{ secrets.DOCKERHUB_REGISTRY }} |
| 34 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 35 | + |
| 36 | + - name: Cache riotdocker-base layer |
| 37 | + uses: actions/cache@v2 |
| 38 | + with: |
| 39 | + path: /tmp/.buildx-cache-base |
| 40 | + key: ${{ runner.os }}-buildx-base-${{ github.sha }} |
| 41 | + restore-keys: ${{ runner.os }}-buildx-base- |
| 42 | + |
| 43 | + - name: Build and push riotdocker-base |
| 44 | + uses: docker/build-push-action@v2 |
| 45 | + with: |
| 46 | + context: ./riotdocker-base |
| 47 | + file: ./riotdocker-base/Dockerfile |
| 48 | + platforms: linux/amd64,linux/arm64,linux/arm/v7 |
| 49 | + pull: true |
| 50 | + push: ${{ github.event_name == 'push' }} |
| 51 | + tags: ${{ secrets.DOCKERHUB_REGISTRY }}/riotdocker-base:latest |
| 52 | + build-args: | |
| 53 | + DOCKERHUB_REGISTRY=${{ secrets.DOCKERHUB_REGISTRY }} |
| 54 | + cache-from: type=local,src=/tmp/.buildx-cache-base |
| 55 | + cache-to: type=local,dest=/tmp/.buildx-cache-base-new |
| 56 | + |
| 57 | + - name: Move cache |
| 58 | + # Temp fix |
| 59 | + # https://github.com/docker/build-push-action/issues/252 |
| 60 | + # https://github.com/moby/buildkit/issues/1896 |
| 61 | + run: | |
| 62 | + rm -rf /tmp/.buildx-cache-base |
| 63 | + mv /tmp/.buildx-cache-base-new /tmp/.buildx-cache-base |
| 64 | +
|
| 65 | + build-flashers: |
| 66 | + needs: build-riotdocker-base |
| 67 | + strategy: |
| 68 | + fail-fast: false |
| 69 | + matrix: |
| 70 | + flasher: [jlink, edbg, openocd] |
| 71 | + name: Build and push ${{ matrix.flasher }} |
| 72 | + runs-on: ubuntu-latest |
| 73 | + steps: |
| 74 | + - name: checkout |
| 75 | + uses: actions/checkout@v2 |
| 76 | + |
| 77 | + - name: Set up QEMU |
| 78 | + uses: docker/setup-qemu-action@v1 |
| 79 | + |
| 80 | + - name: Set up Docker Buildx |
| 81 | + uses: docker/setup-buildx-action@v1 |
| 82 | + |
| 83 | + - name: Login to DockerHub |
| 84 | + uses: docker/login-action@v1 |
| 85 | + with: |
| 86 | + username: ${{ secrets.DOCKERHUB_REGISTRY }} |
| 87 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 88 | + |
| 89 | + - name: Cache ${{ matrix.flasher }} |
| 90 | + uses: actions/cache@v2 |
| 91 | + with: |
| 92 | + path: /tmp/.buildx-cache-${{ matrix.flasher }} |
| 93 | + key: ${{ runner.os }}-buildx-${{ matrix.flasher }}-${{ github.sha }} |
| 94 | + restore-keys: ${{ runner.os }}-buildx-${{ matrix.flasher }}- |
| 95 | + |
| 96 | + - name: Build and push ${{ matrix.flasher }} |
| 97 | + uses: docker/build-push-action@v2 |
| 98 | + with: |
| 99 | + context: . |
| 100 | + file: ./flashers/${{ matrix.flasher }}.Dockerfile |
| 101 | + platforms: linux/amd64,linux/arm64,linux/arm/v7 |
| 102 | + pull: true |
| 103 | + push: ${{ github.event_name == 'push' }} |
| 104 | + tags: ${{ secrets.DOCKERHUB_REGISTRY }}/${{ matrix.flasher }}:latest |
| 105 | + build-args: | |
| 106 | + DOCKERHUB_REGISTRY=${{ secrets.DOCKERHUB_REGISTRY }} |
| 107 | + cache-from: type=local,src=/tmp/.buildx-cache-${{ matrix.flasher }} |
| 108 | + cache-to: type=local,dest=/tmp/.buildx-cache-${{ matrix.flasher }}-new |
| 109 | + |
| 110 | + - name: Move cache |
| 111 | + # Temp fix |
| 112 | + # https://github.com/docker/build-push-action/issues/252 |
| 113 | + # https://github.com/moby/buildkit/issues/1896 |
| 114 | + run: | |
| 115 | + rm -rf /tmp/.buildx-cache-${{ matrix.flasher }} |
| 116 | + mv /tmp/.buildx-cache-${{ matrix.flasher }}-new /tmp/.buildx-cache-${{ matrix.flasher }} |
0 commit comments