docker.yml 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. name: Build Docker image
  2. on:
  3. on: workflow_dispatch
  4. release:
  5. types:
  6. - created
  7. env:
  8. DOCKER_IMAGE: archivebox-ci
  9. jobs:
  10. buildx:
  11. runs-on: ubuntu-latest
  12. steps:
  13. - name: Checkout
  14. uses: actions/checkout@v2
  15. with:
  16. submodules: true
  17. fetch-depth: 1
  18. - name: Set up QEMU
  19. uses: docker/setup-qemu-action@v1
  20. - name: Set up Docker Buildx
  21. id: buildx
  22. uses: docker/setup-buildx-action@v1
  23. with:
  24. version: latest
  25. install: true
  26. - name: Builder instance name
  27. run: echo ${{ steps.buildx.outputs.name }}
  28. - name: Available platforms
  29. run: echo ${{ steps.buildx.outputs.platforms }}
  30. - name: Cache Docker layers
  31. uses: actions/cache@v2
  32. with:
  33. path: /tmp/.buildx-cache
  34. key: ${{ runner.os }}-buildx-${{ github.sha }}
  35. restore-keys: |
  36. ${{ runner.os }}-buildx-
  37. - name: Docker Login
  38. uses: docker/login-action@v1
  39. if: github.event_name != 'pull_request'
  40. with:
  41. username: ${{ secrets.DOCKER_USERNAME }}
  42. password: ${{ secrets.DOCKER_PASSWORD }}
  43. - name: Collect Docker tags
  44. id: docker_meta
  45. uses: crazy-max/ghaction-docker-meta@v1
  46. with:
  47. images: archivebox/archivebox,nikisweeting/archivebox
  48. tag-sha: true
  49. tag-semver: |
  50. {{version}}
  51. {{major}}.{{minor}}
  52. - name: Build and push
  53. id: docker_build
  54. uses: docker/build-push-action@v2
  55. with:
  56. context: ./
  57. file: ./Dockerfile
  58. builder: ${{ steps.buildx.outputs.name }}
  59. push: ${{ github.event_name != 'pull_request' }}
  60. tags: ${{ steps.docker_meta.outputs.tags }}
  61. cache-from: type=local,src=/tmp/.buildx-cache
  62. cache-to: type=local,dest=/tmp/.buildx-cache
  63. platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7
  64. - name: Image digest
  65. run: echo ${{ steps.docker_build.outputs.digest }}