chore: add build id to settings page (#6873)

- Adds a build Id to the settings page
This commit is contained in:
Vishnu Narayanan
2023-04-18 00:35:35 +05:30
committed by GitHub
parent c9ce9e5b8f
commit 4505c5dda3
8 changed files with 31 additions and 6 deletions

View File

@@ -1,8 +1,6 @@
.bundle
.env
.env.*
.git
.gitignore
docker-compose.*
docker/Dockerfile
docker/dockerfiles

2
.gitignore vendored
View File

@@ -61,7 +61,7 @@ test/cypress/videos/*
/config/master.key
/config/*.enc
.vscode/settings.json
#ignore files under .vscode directory
.vscode
# yalc for local testing

View File

@@ -1,3 +1,3 @@
release: POSTGRES_STATEMENT_TIMEOUT=600s bundle exec rails db:chatwoot_prepare
release: POSTGRES_STATEMENT_TIMEOUT=600s bundle exec rails db:chatwoot_prepare && echo $SOURCE_VERSION > .git_sha
web: bundle exec rails ip_lookup:setup && bin/rails server -p $PORT -e $RAILS_ENV
worker: bundle exec rails ip_lookup:setup && bundle exec sidekiq -C config/sidekiq.yml

View File

@@ -56,7 +56,8 @@ class DashboardController < ActionController::Base
FB_APP_ID: GlobalConfigService.load('FB_APP_ID', ''),
FACEBOOK_API_VERSION: 'v14.0',
IS_ENTERPRISE: ChatwootApp.enterprise?,
AZURE_APP_ID: ENV.fetch('AZURE_APP_ID', '')
AZURE_APP_ID: ENV.fetch('AZURE_APP_ID', ''),
GIT_SHA: GIT_HASH
}
end
end

View File

@@ -104,6 +104,9 @@
})
}}
</div>
<div class="build-id">
<div>{{ `Build ${globalConfig.gitSha}` }}</div>
</div>
</div>
<woot-submit-button

View File

@@ -9,6 +9,7 @@ const {
CREATE_NEW_ACCOUNT_FROM_DASHBOARD: createNewAccountFromDashboard,
DIRECT_UPLOADS_ENABLED: directUploadsEnabled,
DISPLAY_MANIFEST: displayManifest,
GIT_SHA: gitSha,
HCAPTCHA_SITE_KEY: hCaptchaSiteKey,
INSTALLATION_NAME: installationName,
LOGO_THUMBNAIL: logoThumbnail,
@@ -33,6 +34,7 @@ const state = {
directUploadsEnabled: directUploadsEnabled === 'true',
disableUserProfileUpdate: disableUserProfileUpdate === 'true',
displayManifest,
gitSha,
hCaptchaSiteKey,
installationName,
logo,

View File

@@ -0,0 +1,13 @@
# Define a method to fetch the git commit hash
def fetch_git_sha
sha = `git rev-parse HEAD`
if sha.present?
sha.strip
elsif File.exist?('.git_sha')
File.read('.git_sha').strip
else
'unknown'
end
end
GIT_HASH = fetch_git_sha

View File

@@ -60,9 +60,14 @@ RUN if [ "$RAILS_ENV" = "production" ]; then \
&& rm -rf spec node_modules tmp/cache; \
fi
# Generate .git_sha file with current commit hash
RUN git rev-parse HEAD > /app/.git_sha
# Remove unnecessary files
RUN rm -rf /gems/ruby/3.1.0/cache/*.gem \
&& find /gems/ruby/3.1.0/gems/ \( -name "*.c" -o -name "*.o" \) -delete
&& find /gems/ruby/3.1.0/gems/ \( -name "*.c" -o -name "*.o" \) -delete \
&& rm -rf .git \
&& rm .gitignore
# final build stage
FROM ruby:3.1.3-alpine3.16
@@ -100,6 +105,9 @@ RUN if [ "$RAILS_ENV" != "production" ]; then \
COPY --from=pre-builder /gems/ /gems/
COPY --from=pre-builder /app /app
# Copy .git_sha file from pre-builder stage
COPY --from=pre-builder /app/.git_sha /app/.git_sha
WORKDIR /app
EXPOSE 3000