|
| 1 | +--- |
| 2 | +name: push docker release images |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + tags: |
| 7 | + - '*' |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v3 |
| 14 | + - name: Install Python 3 |
| 15 | + uses: actions/setup-python@v4 |
| 16 | + with: |
| 17 | + python-version: 3.8 |
| 18 | + - name: Install dependencies |
| 19 | + run: | |
| 20 | + python -m pip install --upgrade pip |
| 21 | + pip install . |
| 22 | + docker: |
| 23 | + needs: build |
| 24 | + runs-on: ubuntu-latest |
| 25 | + steps: |
| 26 | + - name: Checkout |
| 27 | + uses: actions/checkout@v3 |
| 28 | + - name: Set up QEMU |
| 29 | + uses: docker/setup-qemu-action@v2 |
| 30 | + - name: Set up Docker Buildx |
| 31 | + uses: docker/setup-buildx-action@v2 |
| 32 | + - name: Cache Docker layers |
| 33 | + uses: actions/cache@v3 |
| 34 | + with: |
| 35 | + path: /tmp/.buildx-cache |
| 36 | + key: ${{ runner.os }}-buildx-${{ github.sha }} |
| 37 | + restore-keys: | |
| 38 | + ${{ runner.os }}-buildx- |
| 39 | + - name: Login to DockerHub |
| 40 | + uses: docker/login-action@v2 |
| 41 | + with: |
| 42 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 43 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 44 | + - name: Build and push |
| 45 | + id: docker_build |
| 46 | + uses: docker/build-push-action@v3 |
| 47 | + with: |
| 48 | + push: true |
| 49 | + tags: mihxil/npo-pyapi:${GITHUB_REF##*/} |
| 50 | + context: . |
| 51 | + file: docker/Dockerfile |
| 52 | + cache-from: type=local,src=/tmp/.buildx-cache |
| 53 | + cache-to: type=local,dest=/tmp/.buildx-cache-new |
| 54 | + - name: Build and push flask |
| 55 | + id: docker_build_flask |
| 56 | + uses: docker/build-push-action@v3 |
| 57 | + with: |
| 58 | + push: true |
| 59 | + tags: mihxil/npo-pyapi-flask:${GITHUB_REF##*/} |
| 60 | + context: flask |
| 61 | + cache-from: type=local,src=/tmp/.buildx-cache |
| 62 | + cache-to: type=local,dest=/tmp/.buildx-cache-new |
| 63 | + - name: Build and push make |
| 64 | + id: docker_build_make |
| 65 | + uses: docker/build-push-action@v3 |
| 66 | + with: |
| 67 | + push: true |
| 68 | + tags: mihxil/npo-pyapi-make:${GITHUB_REF##*/} |
| 69 | + context: docker/make |
| 70 | + cache-from: type=local,src=/tmp/.buildx-cache |
| 71 | + cache-to: type=local,dest=/tmp/.buildx-cache-new |
| 72 | + - name: Image digest |
| 73 | + run: echo ${{ steps.docker_build.outputs.digest }} |
| 74 | + # This ugly bit is necessary if you don't want your cache to grow forever |
| 75 | + # till it hits GitHub's limit of 5GB. |
| 76 | + # Temp fix |
| 77 | + # https://github.com/docker/build-push-action/issues/252 |
| 78 | + # https://github.com/moby/buildkit/issues/1896 |
| 79 | + - name: Move cache |
| 80 | + run: | |
| 81 | + rm -rf /tmp/.buildx-cache |
| 82 | + mv /tmp/.buildx-cache-new /tmp/.buildx-cache |
0 commit comments