self-hosted.yml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. - name: Step configurations
  25. id: config
  26. run: |
  27. echo "webpack-path=.webpack_cache" >> "$GITHUB_OUTPUT"
  28. echo "WEBPACK_CACHE_PATH=.webpack_cache" >> "$GITHUB_ENV"
  29. - name: webpack cache
  30. uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
  31. with:
  32. path: ${{ steps.config.outputs.webpack-path }}
  33. key: ${{ runner.os }}-self-hosted-webpack-cache-${{ hashFiles('webpack.config.ts') }}
  34. - name: node_modules cache
  35. uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
  36. id: nodemodulescache
  37. with:
  38. path: node_modules
  39. key: ${{ runner.os }}-self-hosted-node-modules-${{ hashFiles('yarn.lock') }}
  40. - name: Install Javascript Dependencies
  41. if: steps.nodemodulescache.outputs.cache-hit != 'true'
  42. run: yarn install --frozen-lockfile --production
  43. - run: |
  44. python setup.py bdist_wheel --build-number 0
  45. cp requirements-frozen.txt dist/
  46. - run: docker login --username '${{ github.actor }}' --password-stdin ghcr.io <<< "$GHCR_TOKEN"
  47. env:
  48. GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  49. if: github.event_name != 'pull_request'
  50. - run: docker buildx create --driver docker-container --use
  51. - run: |
  52. if [ ${{ github.event_name }} = 'push' ]; then
  53. args=(
  54. --tag ghcr.io/getsentry/sentry-self-hosted:latest
  55. --push
  56. )
  57. else
  58. args=()
  59. fi
  60. docker buildx build \
  61. --pull \
  62. --cache-from ghcr.io/getsentry/sentry-self-hosted:latest \
  63. --cache-to type=inline \
  64. --tag ghcr.io/getsentry/sentry-self-hosted:${{ github.sha }} \
  65. --file self-hosted/Dockerfile \
  66. --build-arg SOURCE_COMMIt=${{ github.sha }} \
  67. "${args[@]}" \
  68. .