2
0

build-v2ray.yml 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. name: Build V2ray
  2. on:
  3. push:
  4. # branches: [ master ]
  5. paths:
  6. - 'v2ray/**'
  7. - '.github/workflows/build-v2ray.yml'
  8. # UTC +8
  9. schedule:
  10. - cron: "0 20 * * *"
  11. # pull_request:
  12. # branches: [ master ]
  13. workflow_dispatch:
  14. jobs:
  15. build-v2ray:
  16. runs-on: ubuntu-latest
  17. steps:
  18. - name: Set Variables
  19. run: |
  20. echo "V2RAY_PRE_VERSION=$(curl -fsSL https://api.github.com/repos/v2fly/v2ray-core/tags | grep '"name":' | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/v//g;s/,//g;s/ //g')" >> $GITHUB_ENV
  21. echo "V2RAY_VERSION=$(curl -fsSL https://api.github.com/repos/v2fly/v2ray-core/releases/latest | grep '"tag_name":' | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/v//g;s/,//g;s/ //g')" >> $GITHUB_ENV
  22. shell: bash
  23. - name: Check Out Repo
  24. uses: actions/checkout@v3
  25. - name: Set up Docker Buildx
  26. uses: docker/setup-buildx-action@v2
  27. id: buildx
  28. - name: Cache Docker layers
  29. uses: actions/cache@v3
  30. with:
  31. path: /tmp/.buildx-cache
  32. key: ${{ runner.os }}-buildx-${{ github.sha }}
  33. restore-keys: |
  34. ${{ runner.os }}-buildx-
  35. - name: Login to Docker Hub
  36. uses: docker/login-action@v2
  37. with:
  38. username: ${{ secrets.DOCKER_HUB_USERNAME }}
  39. password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
  40. - name: Build and push Docker images
  41. uses: docker/build-push-action@v3
  42. id: docker_build_v2ray_core_pre
  43. with:
  44. context: ./v2ray
  45. file: ./v2ray/Dockerfile
  46. push: true
  47. tags: |
  48. ${{ secrets.DOCKER_HUB_USERNAME }}/v2ray:latest
  49. ${{ secrets.DOCKER_HUB_USERNAME }}/v2ray:${{ env.V2RAY_PRE_VERSION }}
  50. builder: ${{ steps.buildx.outputs.name }}
  51. cache-from: type=local,src=/tmp/.buildx-cache
  52. cache-to: type=local,dest=/tmp/.buildx-cache-new
  53. - name: Build and push Docker images
  54. uses: docker/build-push-action@v3
  55. id: docker_build_v2ray_core
  56. with:
  57. context: ./v2ray
  58. file: ./v2ray/Dockerfile.fly
  59. push: true
  60. tags: |
  61. ${{ secrets.DOCKER_HUB_USERNAME }}/v2ray:${{ env.V2RAY_VERSION }}
  62. builder: ${{ steps.buildx.outputs.name }}
  63. cache-from: type=local,src=/tmp/.buildx-cache
  64. cache-to: type=local,dest=/tmp/.buildx-cache-new
  65. - name: Move cache
  66. run: |
  67. rm -rf /tmp/.buildx-cache
  68. mv /tmp/.buildx-cache-new /tmp/.buildx-cache
  69. - name: Image digest
  70. run: |
  71. echo ${{ steps.docker_build_v2ray_core_pre.outputs.digest }}
  72. echo ${{ steps.docker_build_v2ray_core.outputs.digest }}