self-hosted.yml 2.6 KB

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