push-docker-test2.yaml 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. name: Another Push to Docker Hub
  2. on:
  3. push:
  4. branches: [ main ]
  5. tags:
  6. - "*.*.*"
  7. pull_request:
  8. branches: [ main ]
  9. jobs:
  10. build:
  11. runs-on: ubuntu-latest
  12. steps:
  13. - name: Checkout
  14. uses: actions/checkout@v3
  15. - name: Docker meta
  16. id: meta
  17. uses: crazy-max/ghaction-docker-meta@v2
  18. with:
  19. # list of Docker images to use as base name for tags
  20. images: |
  21. learningathome/petals
  22. # generate Docker tags based on the following events/attributes
  23. tags: |
  24. type=ref,event=branch
  25. type=ref,event=pr
  26. type=semver,pattern={{version}}
  27. type=semver,pattern={{major}}.{{minor}}
  28. type=semver,pattern={{major}}
  29. - name: Set up Docker Buildx
  30. id: buildxx
  31. uses: docker/setup-buildx-action@v1
  32. - name: Login to Docker Hub
  33. if: github.event_name != 'pull_request'
  34. uses: docker/login-action@v1
  35. with:
  36. username: ${{ secrets.DOCKER_HUB_USERNAME }}
  37. password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
  38. - name: Free disk space on Ubuntu runner
  39. uses: kfir4444/free-disk-space@main
  40. with:
  41. # frees about 6 GB, warning: may remove required tools
  42. tool-cache: false
  43. android: true
  44. dotnet: true
  45. haskell: true
  46. large-packages: true
  47. swap-storage: true
  48. - name: Build and push
  49. id: docker_buildd
  50. uses: docker/build-push-action@v5
  51. with:
  52. context: .
  53. push: ${{ github.event_name != 'pull_request' }}
  54. tags: ${{ steps.meta.outputs.tags }}
  55. - name: Image digest
  56. run: echo ${{ steps.docker_build.outputs.digest }}