Skip to content

Commit

Permalink
Add GITHUB_SHA environment variable to CI and deployment workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
better-salmon authored and razzeee committed Mar 1, 2024
1 parent 40cd556 commit d2960cc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/frontend_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ jobs:
run: yarn build
env:
CI: true
GITHUB_SHA: ${{ github.sha }}
1 change: 1 addition & 0 deletions .github/workflows/frontend_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
NEXT_PUBLIC_IS_PRODUCTION=true
ENABLE_SENTRY=true
SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
GITHUB_SHA=${{ github.sha }}
tags: |
ghcr.io/flathub-infra/frontend:${{ github.sha }}
ghcr.io/flathub-infra/frontend:latest
Expand Down
5 changes: 5 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ FROM base as builder
ARG NEXT_PUBLIC_IS_PRODUCTION=false
ARG ENABLE_SENTRY=false
ARG SENTRY_AUTH_TOKEN
ARG GITHUB_SHA

ENV GITHUB_SHA=$GITHUB_SHA

WORKDIR /app
COPY --from=dev /app/node_modules ./node_modules
Expand All @@ -25,7 +28,9 @@ RUN yarn build

FROM node:18-slim as prod
ARG NEXT_PUBLIC_IS_PRODUCTION=false
ARG GITHUB_SHA

ENV GITHUB_SHA=$GITHUB_SHA
ENV NODE_ENV production
ENV PORT 3000
EXPOSE 3000
Expand Down
7 changes: 7 additions & 0 deletions frontend/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ const nextConfig = (phase) => ({
},
]
},
async generateBuildId() {
if (!process.env.GITHUB_SHA) {
throw new Error("GITHUB_SHA is not set")
}

return process.env.GITHUB_SHA
},
})

const sentryExports = (phase) => {
Expand Down

0 comments on commit d2960cc

Please sign in to comment.