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.

73 lines
2.1 KiB

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