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 registry: ghcr.io
username: ${{ secrets.GHCR_USERNAME }} username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_PASSWORD }} 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 - name: Build docker image
uses: docker/build-push-action@v4 uses: docker/build-push-action@v4
with: with:
@ -24,4 +28,6 @@ jobs:
push: true push: true
tags: ghcr.io/cgduncan7/autobaan:latest tags: ghcr.io/cgduncan7/autobaan:latest
cache-from: type=gha cache-from: type=gha
cache-to: type=gha,mode=max 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 CXX=g++-12 npm install
RUN npm run migrations RUN npm run migrations
ARG GIT_COMMIT
ENV GIT_COMMIT ${GIT_COMMIT:-unknown}
ENTRYPOINT ["npm", "run", "start"] ENTRYPOINT ["npm", "run", "start"]

View file

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