build-and-push-image.yml 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. name: Build Image and Publish to Dockerhub & GPR
  2. on:
  3. release:
  4. types: [ published ]
  5. workflow_dispatch:
  6. inputs:
  7. tag:
  8. description: 'Image tag'
  9. required: true
  10. default: 'test'
  11. permissions:
  12. contents: read
  13. jobs:
  14. image:
  15. name: Build Image from Dockerfile and binaries
  16. runs-on: ubuntu-latest
  17. steps:
  18. # environment
  19. - name: Checkout
  20. uses: actions/checkout@v4
  21. with:
  22. fetch-depth: '0'
  23. - name: Set up QEMU
  24. uses: docker/setup-qemu-action@v3
  25. - name: Set up Docker Buildx
  26. uses: docker/setup-buildx-action@v3
  27. # get image tag name
  28. - name: Get Image Tag Name
  29. run: |
  30. if [ x${{ github.event.inputs.tag }} == x"" ]; then
  31. echo "TAG_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
  32. else
  33. echo "TAG_NAME=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
  34. fi
  35. - name: Login to DockerHub
  36. uses: docker/login-action@v3
  37. with:
  38. username: ${{ secrets.DOCKERHUB_USERNAME }}
  39. password: ${{ secrets.DOCKERHUB_PASSWORD }}
  40. - name: Login to the GPR
  41. uses: docker/login-action@v3
  42. with:
  43. registry: ghcr.io
  44. username: ${{ github.repository_owner }}
  45. password: ${{ secrets.GPR_TOKEN }}
  46. # prepare image tags
  47. - name: Prepare Image Tags
  48. run: |
  49. echo "DOCKERFILE_FRPC_PATH=dockerfiles/Dockerfile-for-frpc" >> $GITHUB_ENV
  50. echo "DOCKERFILE_FRPS_PATH=dockerfiles/Dockerfile-for-frps" >> $GITHUB_ENV
  51. echo "TAG_FRPC=fatedier/frpc:${{ env.TAG_NAME }}" >> $GITHUB_ENV
  52. echo "TAG_FRPS=fatedier/frps:${{ env.TAG_NAME }}" >> $GITHUB_ENV
  53. echo "TAG_FRPC_GPR=ghcr.io/fatedier/frpc:${{ env.TAG_NAME }}" >> $GITHUB_ENV
  54. echo "TAG_FRPS_GPR=ghcr.io/fatedier/frps:${{ env.TAG_NAME }}" >> $GITHUB_ENV
  55. - name: Build and push frpc
  56. uses: docker/build-push-action@v5
  57. with:
  58. context: .
  59. file: ./dockerfiles/Dockerfile-for-frpc
  60. platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
  61. push: true
  62. tags: |
  63. ${{ env.TAG_FRPC }}
  64. ${{ env.TAG_FRPC_GPR }}
  65. - name: Build and push frps
  66. uses: docker/build-push-action@v5
  67. with:
  68. context: .
  69. file: ./dockerfiles/Dockerfile-for-frps
  70. platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
  71. push: true
  72. tags: |
  73. ${{ env.TAG_FRPS }}
  74. ${{ env.TAG_FRPS_GPR }}