build-and-push-image.yml 2.5 KB

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