You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.9 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. name: Build DockerHub
  2. on:
  3. push:
  4. branches:
  5. - '*'
  6. tags:
  7. - '*'
  8. jobs:
  9. CheckToken:
  10. runs-on: ubuntu-latest
  11. outputs:
  12. hasToken: ${{ steps.step_one.outputs.hasToken }}
  13. env:
  14. DOCKER_PASSWORD : ${{ secrets.DOCKER_PASSWORD }}
  15. steps:
  16. - name: Set the value
  17. id: step_one
  18. run: |
  19. if [ "$DOCKER_PASSWORD" ] ; then
  20. echo "::set-output name=hasToken::true"
  21. else
  22. echo "::set-output name=hasToken::false"
  23. fi
  24. - name: Check the value
  25. run: echo ${{ steps.step_one.outputs.hasToken }}
  26. build:
  27. runs-on: ubuntu-latest
  28. needs: CheckToken
  29. if: "contains(needs.CheckToken.outputs.hasToken, 'true')"
  30. steps:
  31. - name: checkout code
  32. uses: actions/checkout@v2
  33. - name: Set up QEMU
  34. uses: docker/setup-qemu-action@v1
  35. - name: Set up Docker Buildx
  36. uses: docker/setup-buildx-action@v1
  37. - name: login to docker hub
  38. run: |
  39. echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
  40. - name: build and push the image
  41. run: |
  42. DOCKER_IMAGE=neilpang/acme.sh
  43. if [[ $GITHUB_REF == refs/tags/* ]]; then
  44. DOCKER_IMAGE_TAG=${GITHUB_REF#refs/tags/}
  45. fi
  46. if [[ $GITHUB_REF == refs/heads/* ]]; then
  47. DOCKER_IMAGE_TAG=${GITHUB_REF#refs/heads/}
  48. if [[ $DOCKER_IMAGE_TAG == master ]]; then
  49. DOCKER_IMAGE_TAG=latest
  50. AUTO_UPGRADE=1
  51. fi
  52. fi
  53. docker buildx build \
  54. --tag ${DOCKER_IMAGE}:${DOCKER_IMAGE_TAG} \
  55. --output "type=image,push=true" \
  56. --build-arg AUTO_UPGRADE=${AUTO_UPGRADE} \
  57. --platform linux/arm64/v8,linux/amd64,linux/arm/v6,linux/arm/v7,linux/386,linux/ppc64le,linux/s390x .