self-hosted.yml 3.0 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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
  23. - uses: getsentry/action-setup-volta@c52be2ea13cfdc084edb806e81958c13e445941e # v1.2.0
  24. - uses: getsentry/action-setup-venv@9e3bbae3836b1b6f129955bf55a19e1d99a61c67 # v1.0.5
  25. with:
  26. python-version: 3.11.6
  27. cache-dependency-path: requirements-dev-frozen.txt
  28. install-cmd: python3 -m tools.hack_pip && pip install pip setuptools wheel -c requirements-dev-frozen.txt
  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. SETUPTOOLS_USE_DISTUTILS=stdlib python setup.py bdist_wheel --build-number 0
  50. cp requirements-frozen.txt dist/
  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. .