docker.yml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. name: Build Docker image
  2. on:
  3. workflow_dispatch:
  4. push:
  5. branches:
  6. - '**'
  7. tags:
  8. - 'v*'
  9. # pull_request:
  10. env:
  11. DOCKER_IMAGE: archivebox-ci
  12. jobs:
  13. buildx:
  14. runs-on: ubuntu-latest
  15. steps:
  16. - name: Checkout
  17. uses: actions/checkout@v4
  18. with:
  19. submodules: true
  20. fetch-depth: 1
  21. - name: Set up QEMU
  22. uses: docker/setup-qemu-action@v3
  23. - name: Set up Docker Buildx
  24. id: buildx
  25. uses: docker/setup-buildx-action@v3
  26. with:
  27. version: latest
  28. install: true
  29. platforms: linux/amd64,linux/arm64
  30. - name: Builder instance name
  31. run: echo ${{ steps.buildx.outputs.name }}
  32. - name: Available platforms
  33. run: echo ${{ steps.buildx.outputs.platforms }}
  34. - name: Cache Docker layers
  35. uses: actions/cache@v3
  36. with:
  37. path: /tmp/.buildx-cache
  38. key: ${{ runner.os }}-buildx-${{ github.sha }}
  39. restore-keys: |
  40. ${{ runner.os }}-buildx-
  41. - name: Docker Login
  42. uses: docker/login-action@v3
  43. if: github.event_name != 'pull_request'
  44. with:
  45. username: ${{ secrets.DOCKER_USERNAME }}
  46. password: ${{ secrets.DOCKER_PASSWORD }}
  47. - name: Collect Docker tags
  48. # https://github.com/docker/metadata-action
  49. id: docker_meta
  50. uses: docker/metadata-action@v5
  51. with:
  52. images: archivebox/archivebox,nikisweeting/archivebox
  53. tags: |
  54. # :stable
  55. type=ref,event=branch
  56. # :0.7.3
  57. type=semver,pattern={{version}}
  58. # :0.7
  59. type=semver,pattern={{major}}.{{minor}}
  60. # :sha-463ea54
  61. type=sha
  62. # :latest
  63. type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'stable') }}
  64. - name: Build and push
  65. id: docker_build
  66. uses: docker/build-push-action@v5
  67. with:
  68. context: ./
  69. file: ./Dockerfile
  70. builder: ${{ steps.buildx.outputs.name }}
  71. push: ${{ github.event_name != 'pull_request' }}
  72. tags: ${{ steps.docker_meta.outputs.tags }}
  73. labels: ${{ steps.docker_meta.outputs.labels }}
  74. cache-from: type=local,src=/tmp/.buildx-cache
  75. cache-to: type=local,dest=/tmp/.buildx-cache-new
  76. platforms: linux/amd64,linux/arm64
  77. - name: Image digest
  78. run: echo ${{ steps.docker_build.outputs.digest }}
  79. - name: Update README
  80. uses: peter-evans/dockerhub-description@v4
  81. with:
  82. username: ${{ secrets.DOCKER_USERNAME }}
  83. password: ${{ secrets.DOCKER_PASSWORD }}
  84. repository: archivebox/archivebox
  85. # This ugly bit is necessary if you don't want your cache to grow forever
  86. # until it hits GitHub's limit of 5GB.
  87. # Temp fix
  88. # https://github.com/docker/build-push-action/issues/252
  89. # https://github.com/moby/buildkit/issues/1896
  90. - name: Move cache
  91. run: |
  92. rm -rf /tmp/.buildx-cache
  93. mv /tmp/.buildx-cache-new /tmp/.buildx-cache