docker-image.yml 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. name: Publish Docker image
  2. on:
  3. push:
  4. tags:
  5. - '*'
  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@v3
  21. - name: Save version info
  22. run: |
  23. git describe --tags > VERSION
  24. - name: Log in to Docker Hub
  25. uses: docker/login-action@v2
  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@v2
  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@v4
  38. with:
  39. images: |
  40. justsong/message-pusher
  41. ghcr.io/${{ github.repository }}
  42. - name: Build and push Docker images
  43. uses: docker/build-push-action@v3
  44. with:
  45. context: .
  46. push: true
  47. tags: ${{ steps.meta.outputs.tags }}
  48. labels: ${{ steps.meta.outputs.labels }}