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.

66 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
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: install buildx
  34. id: buildx
  35. uses: crazy-max/ghaction-docker-buildx@v3
  36. with:
  37. buildx-version: latest
  38. qemu-version: latest
  39. - name: login to docker hub
  40. run: |
  41. echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
  42. - name: build and push the image
  43. run: |
  44. DOCKER_IMAGE=neilpang/acme.sh
  45. if [[ $GITHUB_REF == refs/tags/* ]]; then
  46. DOCKER_IMAGE_TAG=${GITHUB_REF#refs/tags/}
  47. fi
  48. if [[ $GITHUB_REF == refs/heads/* ]]; then
  49. DOCKER_IMAGE_TAG=${GITHUB_REF#refs/heads/}
  50. if [[ $DOCKER_IMAGE_TAG == master ]]; then
  51. DOCKER_IMAGE_TAG=latest
  52. AUTO_UPGRADE=1
  53. fi
  54. fi
  55. docker buildx build \
  56. --tag ${DOCKER_IMAGE}:${DOCKER_IMAGE_TAG} \
  57. --output "type=image,push=true" \
  58. --build-arg AUTO_UPGRADE=${AUTO_UPGRADE} \
  59. --platform linux/arm64/v8,linux/amd64,linux/arm/v6,linux/arm/v7,linux/386,linux/ppc64le,linux/s390x .