self-hosted.yml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. name: self-hosted
  2. on:
  3. push:
  4. branches:
  5. - master
  6. - releases/**
  7. pull_request:
  8. # Cancel in progress workflows on pull_requests.
  9. # https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
  10. concurrency:
  11. group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  12. cancel-in-progress: true
  13. # hack for https://github.com/actions/cache/issues/810#issuecomment-1222550359
  14. env:
  15. SEGMENT_DOWNLOAD_TIMEOUT_MINS: 3
  16. NODE_OPTIONS: '--max-old-space-size=4096'
  17. jobs:
  18. self-hosted:
  19. runs-on: ubuntu-latest
  20. timeout-minutes: 30
  21. steps:
  22. - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
  23. - uses: getsentry/action-setup-volta@e4939d337b83760d13a9d7030a6f68c9d0ee7581 # v2.0.0
  24. - uses: getsentry/action-setup-venv@a133e6fd5fa6abd3f590a1c106abda344f5df69f # v2.1.0
  25. with:
  26. python-version: 3.11.6
  27. cache-dependency-path: requirements-dev-frozen.txt
  28. install-cmd: python3 -m tools.hack_pip
  29. - name: Step configurations
  30. id: config
  31. run: |
  32. echo "webpack-path=.webpack_cache" >> "$GITHUB_OUTPUT"
  33. echo "WEBPACK_CACHE_PATH=.webpack_cache" >> "$GITHUB_ENV"
  34. - name: webpack cache
  35. uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
  36. with:
  37. path: ${{ steps.config.outputs.webpack-path }}
  38. key: ${{ runner.os }}-self-hosted-webpack-cache-${{ hashFiles('webpack.config.ts') }}
  39. - name: node_modules cache
  40. uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
  41. id: nodemodulescache
  42. with:
  43. path: node_modules
  44. key: ${{ runner.os }}-self-hosted-node-modules-${{ hashFiles('yarn.lock') }}
  45. - name: Install Javascript Dependencies
  46. if: steps.nodemodulescache.outputs.cache-hit != 'true'
  47. run: yarn install --frozen-lockfile --production
  48. - run: |
  49. python3 -m tools.fast_editable --path .
  50. python3 -m sentry.build.main
  51. - run: docker login --username '${{ github.actor }}' --password-stdin ghcr.io <<< "$GHCR_TOKEN"
  52. env:
  53. GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  54. if: github.event_name != 'pull_request'
  55. - run: docker buildx create --driver docker-container --use
  56. - run: |
  57. if [ ${{ github.event_name }} = 'push' ]; then
  58. args=(
  59. --tag ghcr.io/getsentry/sentry-self-hosted:latest
  60. --push
  61. )
  62. else
  63. args=()
  64. fi
  65. docker buildx build \
  66. --pull \
  67. --cache-from ghcr.io/getsentry/sentry-self-hosted:latest \
  68. --cache-to type=inline \
  69. --tag ghcr.io/getsentry/sentry-self-hosted:${{ github.sha }} \
  70. --file self-hosted/Dockerfile \
  71. --build-arg SOURCE_COMMIt=${{ github.sha }} \
  72. "${args[@]}" \
  73. .