build-php.yml 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. name: Build PHP
  2. on:
  3. # push:
  4. # branches: [ master ]
  5. # paths:
  6. # - 'php/**'
  7. # - '.github/workflows/build-php.yml'
  8. # UTC +8
  9. # schedule:
  10. # - cron: "0 20 * * *"
  11. # pull_request:
  12. # branches: [ master ]
  13. workflow_dispatch:
  14. jobs:
  15. build-php:
  16. runs-on: ubuntu-latest
  17. steps:
  18. - name: Check Out Repo
  19. uses: actions/checkout@v3
  20. - name: Set up Docker Buildx
  21. uses: docker/setup-buildx-action@v2
  22. id: buildx
  23. - name: Cache Docker layers
  24. uses: actions/cache@v3
  25. with:
  26. path: /tmp/.buildx-cache
  27. key: ${{ runner.os }}-buildx-${{ github.sha }}
  28. restore-keys: |
  29. ${{ runner.os }}-buildx-
  30. - name: Login to Docker Hub
  31. uses: docker/login-action@v2
  32. with:
  33. username: ${{ secrets.DOCKER_HUB_USERNAME }}
  34. password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
  35. - name: Build and push Docker images
  36. uses: docker/build-push-action@v3
  37. id: docker_build_php_core
  38. with:
  39. context: ./php
  40. file: ./php/Dockerfile
  41. push: true
  42. tags: |
  43. ${{ secrets.DOCKER_HUB_USERNAME }}/php:latest
  44. ${{ secrets.DOCKER_HUB_USERNAME }}/php:7.4-fpm-alpine
  45. builder: ${{ steps.buildx.outputs.name }}
  46. cache-from: type=local,src=/tmp/.buildx-cache
  47. cache-to: type=local,dest=/tmp/.buildx-cache-new
  48. - name: Build and push Docker images
  49. uses: docker/build-push-action@v3
  50. id: docker_build_php
  51. with:
  52. context: ./php
  53. file: ./php/Dockerfile.latest
  54. push: true
  55. tags: |
  56. ${{ secrets.DOCKER_HUB_USERNAME }}/php:7.4
  57. builder: ${{ steps.buildx.outputs.name }}
  58. cache-from: type=local,src=/tmp/.buildx-cache
  59. cache-to: type=local,dest=/tmp/.buildx-cache-new
  60. - name: Move cache
  61. run: |
  62. rm -rf /tmp/.buildx-cache
  63. mv /tmp/.buildx-cache-new /tmp/.buildx-cache
  64. - name: Image digest
  65. run: |
  66. echo ${{ steps.docker_build_php_core.outputs.digest }}
  67. echo ${{ steps.docker_build_php.outputs.digest }}