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

Add optional param for HerokuStackVersion #12

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ _branch only capable for Git Deployment_

**dir** - Application directory in git repository for more complex repositories. The default is root dir. this works for both Dockerfile and Git Deployment.

**herokuStackVersion** - if you want to specify the stack version. Default is 22 (`heroku-22`)

Good:

```yml
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ inputs:
herokuApiKey:
description: "Heroku API key"
required: true
herokuStackVersion:
description: "Heroku Stack Version Number"
required: false
useDocker:
description: "Deploy the container image (Dockerfile) to Heroku"
default: "false"
Expand Down
4 changes: 2 additions & 2 deletions src/git/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as core from "@actions/core";
import { execSync } from "child_process";
import { checkShallow, gitStack } from "./utils";

const gitDeploymentFn = (AppName: string, HerokuApiKey: string) => {
const gitDeploymentFn = (AppName: string, HerokuApiKey: string, herokuStack: string) => {
try {
execSync(`cat >~/.netrc <<EOF
machine api.heroku.com
Expand All @@ -17,7 +17,7 @@ const gitDeploymentFn = (AppName: string, HerokuApiKey: string) => {
execSync(`heroku git:remote -a ${AppName}`);
core.info("✅ set git remote ✅");
checkShallow();
gitStack(AppName);
gitStack(AppName, herokuStack);
if (appDir) {
execSync(
`git push heroku \`git subtree split --prefix ${appDir} ${head}\`:refs/heads/main --force`
Expand Down
4 changes: 2 additions & 2 deletions src/git/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export const checkShallow = (): void => {
console.log("git unshallow repository🔄");
}
};
export const gitStack = (AppName: string): void => {
execSync("heroku stack:set heroku-22");
export const gitStack = (AppName: string, Stack: string): void => {
execSync(`heroku stack:set heroku-${Stack}`);
execSync("heroku plugins:install heroku-repo");
execSync(`heroku repo:reset -a ${AppName}`);
};
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import gitDeployment from "./git/main";
process.env.HEROKU_API_KEY = HerokuApiKey;
const appName = core.getInput("herokuAppName");
core.info(`Application Name: ${appName}`);
const herokuStack = core.getInput("herokuStackVersion") || "22";
const useDocker = core.getBooleanInput("useDocker");
if (useDocker) {
console.log("🐋 deployment with Docker 🐋");
dockerDeployment(appName);
} else {
console.log("🐈 deployment with Git 🐈");
gitDeployment(appName, HerokuApiKey);
gitDeployment(appName, HerokuApiKey, herokuStack);
}
} catch (error) {
core.setFailed(error as string);
Expand Down