build-image.yml 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. name: Build container image
  2. on:
  3. workflow_dispatch:
  4. push:
  5. branches:
  6. - 'main'
  7. tags:
  8. - '*'
  9. pull_request:
  10. paths:
  11. - .github/workflows/build-image.yml
  12. - Dockerfile
  13. permissions:
  14. contents: read
  15. jobs:
  16. build-image:
  17. runs-on: ubuntu-latest
  18. steps:
  19. - uses: actions/checkout@v3
  20. - uses: hadolint/hadolint-action@v3.0.0
  21. - uses: docker/setup-qemu-action@v2
  22. - uses: docker/setup-buildx-action@v2
  23. - uses: docker/login-action@v2
  24. with:
  25. username: ${{ secrets.DOCKERHUB_USERNAME }}
  26. password: ${{ secrets.DOCKERHUB_TOKEN }}
  27. if: github.event_name != 'pull_request'
  28. - uses: docker/metadata-action@v4
  29. id: meta
  30. with:
  31. images: tootsuite/mastodon
  32. flavor: |
  33. latest=auto
  34. tags: |
  35. type=edge,branch=main
  36. type=pep440,pattern={{raw}}
  37. type=pep440,pattern=v{{major}}.{{minor}}
  38. type=ref,event=pr
  39. - uses: docker/build-push-action@v3
  40. with:
  41. context: .
  42. platforms: linux/amd64,linux/arm64
  43. builder: ${{ steps.buildx.outputs.name }}
  44. push: ${{ github.event_name != 'pull_request' }}
  45. tags: ${{ steps.meta.outputs.tags }}
  46. cache-from: type=gha
  47. cache-to: type=gha,mode=max