publish-dockerhub.yml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. name: Publish Sentry image to DockerHub
  2. on:
  3. push:
  4. branches:
  5. - master
  6. - releases/**
  7. jobs:
  8. publish-sentry:
  9. runs-on: ubuntu-22.04
  10. steps:
  11. - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
  12. - name: Pull the test image
  13. id: image_pull
  14. env:
  15. IMAGE_URL: ghcr.io/getsentry/sentry-self-hosted:${{ github.sha }}
  16. shell: bash
  17. run: |
  18. echo "We poll for the Docker image that the GCB/GHA build produces until it succeeds or this job times out."
  19. echo "Polling for $IMAGE_URL"
  20. timeout 20m bash -c 'until docker pull "$IMAGE_URL" 2>/dev/null; do sleep 10; done'
  21. - name: Get short SHA for docker tag
  22. id: short_sha
  23. shell: bash
  24. run: |
  25. SHORT_SHA=$(git rev-parse --short "$GITHUB_SHA")
  26. if [[ -z "$SHORT_SHA" ]]; then
  27. echo "Short SHA empty? Re-running rev-parse."
  28. git rev-parse --short "$GITHUB_SHA"
  29. else
  30. echo "sha=$SHORT_SHA" >> $GITHUB_OUTPUT
  31. fi
  32. - name: Push built docker image
  33. shell: bash
  34. env:
  35. SHORT_SHA: ${{ steps.short_sha.outputs.sha }}
  36. IMAGE_URL: ghcr.io/getsentry/sentry-self-hosted:${{ github.sha }}
  37. run: |
  38. # only login if the password is set
  39. if [[ "${{ secrets.DOCKER_HUB_RW_TOKEN }}" ]]; then echo "${{ secrets.DOCKER_HUB_RW_TOKEN }}" | docker login --username=sentrybuilder --password-stdin; fi
  40. # We push 3 tags to Dockerhub:
  41. # first, the full sha of the commit
  42. docker tag ${IMAGE_URL} getsentry/sentry:${GITHUB_SHA}
  43. docker push getsentry/sentry:${GITHUB_SHA}
  44. # second, the short sha of the commit
  45. docker tag ${IMAGE_URL} getsentry/sentry:${SHORT_SHA}
  46. docker push getsentry/sentry:${SHORT_SHA}
  47. # finally, nightly
  48. docker tag ${IMAGE_URL} getsentry/sentry:nightly
  49. docker push getsentry/sentry:nightly