self-hosted.yml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
  24. id: setup-node
  25. with:
  26. node-version-file: '.volta.json'
  27. - uses: getsentry/action-setup-venv@a133e6fd5fa6abd3f590a1c106abda344f5df69f # v2.1.0
  28. with:
  29. python-version: 3.12.6
  30. cache-dependency-path: requirements-dev-frozen.txt
  31. install-cmd: python3 -m tools.hack_pip
  32. - name: Step configurations
  33. id: config
  34. run: |
  35. echo "webpack-path=.webpack_cache" >> "$GITHUB_OUTPUT"
  36. echo "WEBPACK_CACHE_PATH=.webpack_cache" >> "$GITHUB_ENV"
  37. - name: webpack cache
  38. uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
  39. with:
  40. path: ${{ steps.config.outputs.webpack-path }}
  41. key: ${{ runner.os }}-self-hosted-webpack-cache-${{ hashFiles('webpack.config.ts') }}
  42. - name: node_modules cache
  43. uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
  44. id: nodemodulescache
  45. with:
  46. path: node_modules
  47. key: ${{ runner.os }}-self-hosted-node-modules-${{ hashFiles('yarn.lock', '.volta.json') }}
  48. - name: Install Javascript Dependencies
  49. if: steps.nodemodulescache.outputs.cache-hit != 'true'
  50. run: yarn install --frozen-lockfile --production
  51. - run: |
  52. python3 -m tools.fast_editable --path .
  53. python3 -m sentry.build.main
  54. - run: docker login --username '${{ github.actor }}' --password-stdin ghcr.io <<< "$GHCR_TOKEN"
  55. env:
  56. GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  57. if: github.event_name != 'pull_request'
  58. - run: docker buildx create --driver docker-container --use
  59. - run: |
  60. if [ ${{ github.event_name }} = 'push' ]; then
  61. args=(
  62. --tag ghcr.io/getsentry/sentry-self-hosted:latest
  63. --push
  64. )
  65. else
  66. args=()
  67. fi
  68. docker buildx build \
  69. --pull \
  70. --cache-from ghcr.io/getsentry/sentry-self-hosted:latest \
  71. --cache-to type=inline \
  72. --tag ghcr.io/getsentry/sentry-self-hosted:${{ github.sha }} \
  73. --file self-hosted/Dockerfile \
  74. --build-arg SOURCE_COMMIT=${{ github.sha }} \
  75. "${args[@]}" \
  76. .