You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.5 KiB

  1. name: Build container image
  2. on:
  3. workflow_dispatch:
  4. push:
  5. branches:
  6. - 'main'
  7. pull_request:
  8. paths:
  9. - .github/workflows/build-image.yml
  10. - Dockerfile
  11. permissions:
  12. contents: read
  13. packages: write
  14. jobs:
  15. build-image:
  16. runs-on: ubuntu-latest
  17. concurrency:
  18. group: ${{ github.workflow }}-${{ github.ref }}
  19. cancel-in-progress: true
  20. steps:
  21. - uses: actions/checkout@v3
  22. - uses: hadolint/hadolint-action@v3.1.0
  23. - uses: docker/setup-qemu-action@v2
  24. - uses: docker/setup-buildx-action@v2
  25. - name: Log in to the Github Container registry
  26. uses: docker/login-action@v2
  27. with:
  28. registry: ghcr.io
  29. username: ${{ github.actor }}
  30. password: ${{ secrets.GITHUB_TOKEN }}
  31. if: github.event_name != 'pull_request'
  32. - uses: docker/metadata-action@v4
  33. id: meta
  34. with:
  35. images: ghcr.io/${{ github.repository_owner }}/mastodon
  36. tags: |
  37. type=raw,value=latest,enable={{is_default_branch}}
  38. type=edge,branch=main
  39. type=sha,prefix=,format=long
  40. - uses: docker/build-push-action@v4
  41. with:
  42. context: .
  43. platforms: linux/amd64,linux/arm64
  44. provenance: false
  45. builder: ${{ steps.buildx.outputs.name }}
  46. push: ${{ github.event_name != 'pull_request' }}
  47. tags: ${{ steps.meta.outputs.tags }}
  48. labels: ${{ steps.meta.outputs.labels }}
  49. cache-from: type=gha
  50. cache-to: type=gha,mode=max