build-and-push-stable-image.yml 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. name: build-and-push-stable-image
  2. on:
  3. push:
  4. tags:
  5. # Run on pushing tags like 'v1.0.0'
  6. - "v*.*.*"
  7. jobs:
  8. build-and-push-stable-image:
  9. runs-on: ubuntu-latest
  10. permissions:
  11. contents: read
  12. packages: write
  13. steps:
  14. - uses: actions/checkout@v4
  15. - name: Set up QEMU
  16. uses: docker/setup-qemu-action@v3
  17. - name: Extract build args
  18. # Extract version from tag name
  19. # Example: tag name `v1.0.0` sets up env.VERSION=1.0.0
  20. run: |
  21. echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
  22. - name: Login to Docker Hub
  23. uses: docker/login-action@v3
  24. with:
  25. username: stevenlgtm
  26. password: ${{ secrets.DOCKER_HUB_TOKEN }}
  27. - name: Login to GitHub Container Registry
  28. uses: docker/login-action@v3
  29. with:
  30. registry: ghcr.io
  31. username: ${{ github.actor }}
  32. password: ${{ github.token }}
  33. - name: Set up Docker Buildx
  34. id: buildx
  35. uses: docker/setup-buildx-action@v3
  36. with:
  37. install: true
  38. version: v0.9.1
  39. - name: Docker meta
  40. id: meta
  41. uses: docker/metadata-action@v5
  42. with:
  43. images: |
  44. neosmemo/memos
  45. ghcr.io/usememos/memos
  46. tags: |
  47. type=semver,pattern={{version}},value=${{ env.VERSION }}
  48. type=semver,pattern={{major}}.{{minor}},value=${{ env.VERSION }}
  49. type=raw,value=stable
  50. flavor: |
  51. latest=true
  52. labels: |
  53. org.opencontainers.image.version=${{ env.VERSION }}
  54. - name: Build and Push
  55. id: docker_build
  56. uses: docker/build-push-action@v6
  57. with:
  58. context: ./
  59. file: ./Dockerfile
  60. platforms: linux/amd64,linux/arm64
  61. push: true
  62. tags: ${{ steps.meta.outputs.tags }}
  63. labels: ${{ steps.meta.outputs.labels }}