From ce812252603722a3585e8c4ad6a022a8e2f384b8 Mon Sep 17 00:00:00 2001 From: Collin Duncan <3679940+cgduncan7@users.noreply.github.com> Date: Wed, 20 Sep 2023 11:03:20 +0200 Subject: [PATCH] Adding GIT_COMMIT to see hash in server --- .github/workflows/main.yml | 8 +++++++- docker/server/Dockerfile | 5 +++++ src/ntfy/provider.ts | 6 ++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e58c69f..a68b120 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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: @@ -24,4 +28,6 @@ jobs: push: true tags: ghcr.io/cgduncan7/autobaan:latest cache-from: type=gha - cache-to: type=gha,mode=max \ No newline at end of file + cache-to: type=gha,mode=max + build-args: + - GIT_COMMIT: ${{ env.GIT_COMMIT }} \ No newline at end of file diff --git a/docker/server/Dockerfile b/docker/server/Dockerfile index 399becb..b5fecd7 100644 --- a/docker/server/Dockerfile +++ b/docker/server/Dockerfile @@ -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"] \ No newline at end of file diff --git a/src/ntfy/provider.ts b/src/ntfy/provider.ts index 3bd828f..a5ec296 100644 --- a/src/ntfy/provider.ts +++ b/src/ntfy/provider.ts @@ -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('GIT_COMMIT') await this.publishQueue.add( ...NtfyProvider.defaultJob({ title: 'Autobaan up and running', + message: `Version ${gitCommit}`, tags: [MessageTags.badminton], }), )