build.yml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. name: "docker build release"
  2. on:
  3. push:
  4. workflow_dispatch:
  5. env:
  6. PROJECT: frps
  7. jobs:
  8. build:
  9. runs-on: ubuntu-latest
  10. steps:
  11. - name: Checkout
  12. uses: actions/checkout@v2.3.5
  13. - name: Set tag
  14. id: tag
  15. run: |
  16. if [[ -n $(cat Dockerfile | awk '{if($1~"ENV" && $2=="VERSION")print $3}') ]]; then
  17. VERSION=$(cat Dockerfile | awk '{if($1~"ENV" && $2=="VERSION")print $3}')
  18. echo "tag=$VERSION" >> $GITHUB_ENV
  19. else
  20. echo "tag=$(date +%Y)-$(date +%m)-$(date +%d)" >> $GITHUB_ENV
  21. fi
  22. - name: Set up QEMU
  23. uses: docker/setup-qemu-action@v1
  24. - name: Set up Docker Buildx
  25. uses: docker/setup-buildx-action@v1
  26. - name: Login Docker Hub
  27. uses: docker/login-action@v1
  28. with:
  29. username: ${{ secrets.DOCKER_USERNAME }}
  30. password: ${{ secrets.DOCKER_PASSWORD }}
  31. - name: Build and push to docker hub
  32. uses: docker/build-push-action@v2
  33. with:
  34. context: .
  35. platforms: linux/amd64,linux/arm64
  36. push: true
  37. tags: |
  38. ${{ secrets.DOCKER_USERNAME }}/${{ env.PROJECT }}:latest
  39. ${{ secrets.DOCKER_USERNAME }}/${{ env.PROJECT }}:${{ env.tag }}
  40. - name: Sync README.md to Docker Hub
  41. uses: ms-jpq/sync-dockerhub-readme@v1
  42. with:
  43. username: ${{ secrets.DOCKER_USERNAME }}
  44. password: ${{ secrets.DOCKER_PASSWORD }}
  45. repository: ${{ secrets.DOCKER_USERNAME }}/${{ env.PROJECT }}
  46. readme: "./README.md"
  47. - name: Login harbor
  48. uses: docker/login-action@v1
  49. with:
  50. registry: ${{ secrets.HARBOR_REGISTRY }}
  51. username: ${{ secrets.HARBOR_USERNAME }}
  52. password: ${{ secrets.HARBOR_PASSWORD }}
  53. - name: Build and push to harbor
  54. uses: docker/build-push-action@v2
  55. with:
  56. context: .
  57. platforms: linux/amd64,linux/arm64
  58. push: true
  59. tags: |
  60. ${{ secrets.HARBOR_REGISTRY }}/${{ secrets.HARBOR_USERNAME }}/${{ env.PROJECT }}:latest
  61. ${{ secrets.HARBOR_REGISTRY }}/${{ secrets.HARBOR_USERNAME }}/${{ env.PROJECT }}:${{ env.tag }}