Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SMTP app deploy #1341

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/smtp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"scripts": {
"build": "pnpm generate && next build",
"check-types": "tsc --noEmit",
"deploy": "tsx --require dotenv/config ./scripts/deploy.ts",
"dev": "pnpm generate && NODE_OPTIONS='--inspect' next dev",
"fetch-schema": "curl https://raw.githubusercontent.com/saleor/saleor/${npm_package_saleor_schemaVersion}/saleor/graphql/schema.graphql > graphql/schema.graphql",
"generate": "graphql-codegen",
Expand Down Expand Up @@ -82,6 +83,7 @@
"@types/react-dom": "18.2.5",
"eslint": "8.46.0",
"eslint-config-saleor": "workspace:*",
"tsx": "4.7.1",
"typescript": "5.1.6"
},
"private": true,
Expand Down
8 changes: 8 additions & 0 deletions apps/smtp/scripts/deploy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { execSync } from "child_process";
import { getReleaseTag } from "../src/release-utils";

const release = getReleaseTag();

console.log("Using release tag:", release);

execSync(`SENTRY_RELEASE='${release}' pnpm run build`, { stdio: "inherit" });
31 changes: 31 additions & 0 deletions apps/smtp/src/release-utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { execSync } from "child_process";
import packageJson from "../package.json";

// todo: move to shared

const getCommitHash = () => {
if (process.env.VERCEL) {
return process.env.VERCEL_GIT_COMMIT_SHA;
}
if (process.env.GITHUB_SHA) {
return process.env.GITHUB_SHA;
}
try {
const result = execSync("git rev-parse HEAD");

return result.toString().trim();
} catch (e) {
console.warn("Cannot fetch commit hash", e);
return null;
}
};

export const getReleaseTag = () => {
const version = packageJson.version;

if (process.env.NODE_ENV === "production" && process.env.ENV === "production") {
return version;
}

return `${version}-${getCommitHash() ?? "<unknown_commit_hash>"}`;
};
9 changes: 7 additions & 2 deletions apps/smtp/turbo.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"extends": ["//"],
"$schema": "https://turbo.build/schema.json",
"extends": ["//"],
"globalPassThroughEnv": ["GITHUB_SHA", "VERCEL_GIT_COMMIT_SHA", "VERCEL_URL", "VERCEL"],
"pipeline": {
"build": {
"deploy": {
"env": [
"APL",
"APP_DEBUG",
Expand All @@ -19,6 +20,10 @@
"SENTRY_DSN",
"SENTRY_AUTH_TOKEN",
"NEXT_PUBLIC_SENTRY_DSN",
"VERCEL_GIT_COMMIT_SHA",
"ENV",
"VERCEL",
"GITHUB_SHA",
"SENTRY_ENVIRONMENT",
"APP_IFRAME_BASE_URL",
"APP_API_BASE_URL"
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading