mikey555
mikey555

Reputation: 454

Can't access Heroku /tmp/build_{sha} build files in Github Action once build has completed

I run a Github Action that deploys my app to Heroku with two relevant steps.

  1. Build Step: push to Heroku, build (including heroku/nodejs buildpack), create JS sourcemaps (among other things).
  2. Sentry Release Step: create a Sentry release, and ideally upload the sourcemaps created in Build Step.

I've noticed in build logs that my build directory is /tmp/build_{sha}/. The project is built here, and sourcemaps therefore would be found in /tmp/build_{sha}/static/dist. The problem is, I can't find the build directory or the sourcemaps in Sentry Release Step, or any step that runs after Build Step has completed.

Following Build Step completion, I've examined /tmp but there's no build_{sha} folder inside. Yet when I run heroku run bash on the deployed dyno, I see sourcemaps in /static/dist and /staticfiles/dist, where I'd expect them. So where did build files go after Build Step and before deployment? Shouldn't build files be accessible throughout the Github Action?

I've had success accessing sourcemaps within Build Step, by using a Sentry Sourcemap buildpack. Obviously this runs during the build. But I would prefer to have this happen in the Github Action. I've also tried the SentryWebpackPlugin but I've determined sourcemaps must be uploaded once webpack has completed - more specifically, once manage.py collectstatic has completed, since this changes the sourcemaps' filenames and I want to upload the final sourcemaps.

I've read that Heroku's ephemeral storage is wiped on restarting the dyno. But I can't even find these files after moving onto another step in my Github Action.

...
- name: Push To Heroku Remote
        run: |
          git fetch --unshallow
          git push --force heroku ${{ github.ref_name }}:master
- name: Create Sentry release
        uses: getsentry/action-release@v1
        env:
          SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
          SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
        with:
          environment: staging
          projects: ${{ secrets.projects }}
          sourcemaps: <PATH_TO_TMP?>/staticfiles/dist

Upvotes: 1

Views: 127

Answers (1)

mikey555
mikey555

Reputation: 454

My solution was to upload sourcemaps during the release phase (release.sh) with sentry-cli. By the time release phase happens, collectstatic has run and sourcemaps have been generated and filenames have been renamed for cache-busting purposes.

Upvotes: 1

Related Questions