docker-image-alpha.yml 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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: Extract metadata (tags, labels) for Docker
  36. id: meta
  37. uses: docker/metadata-action@v5
  38. with:
  39. images: |
  40. calciumion/new-api
  41. ghcr.io/${{ github.repository }}
  42. tags: |
  43. type=raw,value=alpha
  44. type=raw,value=alpha-{{date 'YYYYMMDD'}}-{{sha}}
  45. - name: Build and push Docker images
  46. uses: docker/build-push-action@v5
  47. with:
  48. context: .
  49. platforms: linux/amd64,linux/arm64
  50. push: true
  51. tags: ${{ steps.meta.outputs.tags }}
  52. labels: ${{ steps.meta.outputs.labels }}