docker-publish.yml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. name: Publish Docker images
  2. on:
  3. push:
  4. branches:
  5. - edge
  6. release:
  7. types: [published]
  8. workflow_dispatch:
  9. # To ensure that if the latest push finishes faster than an earlier run, the previous run won't
  10. # overwrite it later. (by queueing the runs)
  11. concurrency:
  12. group: docker-publish-${{ github.ref_name }} # e.g. docker-publish-edge, docker-publish-latest, docker-publish-1.29.1
  13. cancel-in-progress: false
  14. permissions: {}
  15. jobs:
  16. build-container-image:
  17. name: Build Docker image ${{ matrix.name }}
  18. runs-on: ubuntu-latest
  19. permissions:
  20. contents: read
  21. packages: write # For uploading to the GitHub container registry (ghcr.io)
  22. strategy:
  23. matrix:
  24. include:
  25. - name: Debian
  26. file: Docker/Dockerfile
  27. flavor: |
  28. latest=auto
  29. tags: |
  30. type=edge,onlatest=false
  31. type=semver,pattern={{version}}
  32. type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/0.') }}
  33. # type=semver,pattern={{major}}.{{minor}}
  34. - name: Alpine
  35. file: Docker/Dockerfile-Alpine
  36. flavor: |
  37. latest=false
  38. tags: |
  39. type=raw,value=alpine,enable=${{ github.ref == 'refs/heads/latest' || startsWith(github.ref, 'refs/tags/') }}
  40. type=edge,suffix=-alpine,onlatest=false
  41. type=semver,pattern={{version}}-alpine
  42. type=semver,pattern={{major}}-alpine,enable=${{ !startsWith(github.ref, 'refs/tags/0.') }}
  43. # type=semver,pattern={{major}}.{{minor}}-alpine
  44. steps:
  45. - name: Set up QEMU
  46. uses: docker/setup-qemu-action@1f40c72289eff860ee54a304f1438e3cff362e0a # v4.3.0
  47. - name: Set up Docker Buildx
  48. uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4.3.0
  49. - name: Checkout
  50. uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
  51. with:
  52. persist-credentials: false
  53. - name: Get FreshRSS version
  54. run: |
  55. FRESHRSS_VERSION=$(sed -n "s/^const FRESHRSS_VERSION = '\(.*\)'.*$/\1/p" constants.php)
  56. echo "$FRESHRSS_VERSION"
  57. echo "FRESHRSS_VERSION=$FRESHRSS_VERSION" >> $GITHUB_ENV
  58. - name: Add metadata to Docker images
  59. id: meta
  60. uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
  61. with:
  62. flavor: ${{ matrix.flavor }}
  63. images: |
  64. docker.io/freshrss/freshrss
  65. ghcr.io/${{ github.repository }}
  66. tags: ${{ matrix.tags }}
  67. labels: |
  68. org.opencontainers.image.url=https://freshrss.org/
  69. org.opencontainers.image.version=${{ env.FRESHRSS_VERSION }}
  70. - name: Login to Docker Hub
  71. if: github.repository_owner == 'FreshRSS'
  72. uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
  73. with:
  74. username: ${{ secrets.DOCKERHUB_USERNAME }}
  75. password: ${{ secrets.DOCKERHUB_TOKEN }}
  76. - name: Login to GitHub Container Registry
  77. if: github.repository_owner == 'FreshRSS'
  78. uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
  79. with:
  80. registry: ghcr.io
  81. username: ${{ github.repository_owner }}
  82. password: ${{ secrets.GITHUB_TOKEN }}
  83. - name: Build and push Docker images
  84. uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
  85. with:
  86. context: . # Switching from git context to path context, needed for .dockerignore to be applied. See: https://github.com/docker/build-push-action#git-context
  87. file: ${{ matrix.file }}
  88. platforms: linux/amd64,linux/arm/v7,linux/arm64
  89. build-args: |
  90. FRESHRSS_VERSION=${{ env.FRESHRSS_VERSION }}
  91. SOURCE_COMMIT=${{ github.sha }}
  92. tags: ${{ steps.meta.outputs.tags }}
  93. labels: ${{ steps.meta.outputs.labels }}
  94. push: ${{ (github.ref == 'refs/heads/latest' || github.ref == 'refs/heads/edge' || startsWith(github.ref, 'refs/tags/')) && github.repository_owner == 'FreshRSS' }}
  95. provenance: mode=max
  96. sbom: true