Adding GIT_COMMIT to see hash in server

This commit is contained in:
Collin Duncan 2023-09-20 11:03:20 +02:00
parent d9ed2f22c1
commit ce81225260
No known key found for this signature in database
3 changed files with 18 additions and 1 deletions

View file

@ -16,6 +16,10 @@ jobs:
registry: ghcr.io
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_PASSWORD }}
- name: Declare GIT_COMMIT
shell: bash
run: |
echo "GIT_COMMIT=$(git rev-parse --short "$GITHUB_SHA")" >> "$GITHUB_ENV"
- name: Build docker image
uses: docker/build-push-action@v4
with:
@ -25,3 +29,5 @@ jobs:
tags: ghcr.io/cgduncan7/autobaan:latest
cache-from: type=gha
cache-to: type=gha,mode=max
build-args:
- GIT_COMMIT: ${{ env.GIT_COMMIT }}

View file

@ -23,4 +23,9 @@ COPY --chown=node:node tsconfig.json tsconfig.json
RUN CXX=g++-12 npm install
RUN npm run migrations
ARG GIT_COMMIT
ENV GIT_COMMIT ${GIT_COMMIT:-unknown}
ENTRYPOINT ["npm", "run", "start"]

View file

@ -1,5 +1,6 @@
import { InjectQueue, Process, Processor } from '@nestjs/bull'
import { Inject, Injectable, OnApplicationBootstrap } from '@nestjs/common'
import { ConfigService } from '@nestjs/config'
import { Job, JobOptions, Queue } from 'bull'
import { Dayjs } from 'dayjs'
@ -15,6 +16,9 @@ import {
@Injectable()
export class NtfyProvider implements OnApplicationBootstrap {
constructor(
@Inject(ConfigService)
private readonly configService: ConfigService,
@Inject(NtfyClient)
private readonly ntfyClient: NtfyClient,
@ -49,9 +53,11 @@ export class NtfyProvider implements OnApplicationBootstrap {
}
async sendBootstrappedNotification() {
const gitCommit = this.configService.get<string>('GIT_COMMIT')
await this.publishQueue.add(
...NtfyProvider.defaultJob({
title: 'Autobaan up and running',
message: `Version ${gitCommit}`,
tags: [MessageTags.badminton],
}),
)