Skip to content

Conversation

jessarcher
Copy link
Member

@jessarcher jessarcher commented Oct 21, 2025

This PR sets a sensible default for the NIGHTWATCH_DEPLOY configuration option.

It will attempt to get a human-friendly tag from git, and will fall back to getting a short hash.

Examples:

  • v1.15.2 - Exact tag match
  • v1.15.2-1-g2451327 - Changes have been committed since last tag
  • 2fd2adb - No tag available

If git or shell_exec is not available, it will safely fall back to an empty string.

There is a performance implication from running these commands, but this is solved by config caching which should always be performed on production systems.

@jessarcher jessarcher force-pushed the deploy-config-default branch from 2e089ba to 5a8cc67 Compare October 21, 2025 00:55
@jessarcher jessarcher force-pushed the deploy-config-default branch from 5a8cc67 to 82f3586 Compare October 21, 2025 01:04
@jessarcher jessarcher marked this pull request as ready for review October 21, 2025 01:07
'enabled' => env('NIGHTWATCH_ENABLED', true),
'token' => env('NIGHTWATCH_TOKEN'),
'deployment' => env('NIGHTWATCH_DEPLOY'),
'deployment' => env('NIGHTWATCH_DEPLOY', rescue(static fn () => trim((string) shell_exec('git describe --tags --always 2>/dev/null')), '', false)),
Copy link
Member

@timacdonald timacdonald Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should look at environment variables in the first instance and only fallback to exec if there is nothing else.

  • Forge: FORGE_DEPLOY_COMMIT
  • Vapor?
  • Cloud?
  • Any other common environment variable used 3rd-party platforms? We've usually opted not to support these, but I wonder if we should. GITHUB_SHA, for example.

If you don't have config cached, we will run this on every request. Do we care about that? I'm sure there are plenty of apps out there that don't cache config, routes, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants