docker-image-alpha.yml 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. name: Publish Docker image (alpha)
  2. on:
  3. push:
  4. branches:
  5. - alpha
  6. workflow_dispatch:
  7. inputs:
  8. name:
  9. description: "reason"
  10. required: false
  11. jobs:
  12. push_to_registries:
  13. name: Push Docker image to multiple registries
  14. runs-on: ubuntu-latest
  15. permissions:
  16. packages: write
  17. contents: read
  18. steps:
  19. - name: Check out the repo
  20. uses: actions/checkout@v4
  21. - name: Save version info
  22. run: |
  23. echo "alpha-$(date +'%Y%m%d')-$(git rev-parse --short HEAD)" > VERSION
  24. - name: Log in to Docker Hub
  25. uses: docker/login-action@v3
  26. with:
  27. username: ${{ secrets.DOCKERHUB_USERNAME }}
  28. password: ${{ secrets.DOCKERHUB_TOKEN }}
  29. - name: Log in to the Container registry
  30. uses: docker/login-action@v3
  31. with:
  32. registry: ghcr.io
  33. username: ${{ github.actor }}
  34. password: ${{ secrets.GITHUB_TOKEN }}
  35. - name: Set up Docker Buildx
  36. uses: docker/setup-buildx-action@v3
  37. - name: Extract metadata (tags, labels) for Docker
  38. id: meta
  39. uses: docker/metadata-action@v5
  40. with:
  41. images: |
  42. calciumion/new-api
  43. ghcr.io/${{ github.repository }}
  44. tags: |
  45. type=raw,value=alpha
  46. type=raw,value=alpha-{{date 'YYYYMMDD'}}-{{sha}}
  47. - name: Build and push Docker images
  48. uses: docker/build-push-action@v5
  49. with:
  50. context: .
  51. platforms: linux/amd64,linux/arm64
  52. push: true
  53. tags: ${{ steps.meta.outputs.tags }}
  54. labels: ${{ steps.meta.outputs.labels }}