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.

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