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

Install recipes only for deployer 6 and earlier #11

Open
wants to merge 1 commit into
base: master
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: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This action makes it easy to deploy your php services using [Github Actions](htt
* Starts the `ssh-agent`
* Loads your deployment SSH private key into the agent
* Configures `known_hosts` with your provided key (or turns of SSH host key checking)
* Installs deployer
* Installs deployer & deployer recipes

## Using the action

Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ inputs:
deployer-version:
description: 'Version of deployer to install'
required: false
deployer-recipes-version:
description: 'Version of deployer recipes to install'
required: false
deployer-skip-install:
description: 'Skip install of deployer (if you are using a locally installed version)'
required: false
Expand Down
20 changes: 20 additions & 0 deletions src/SetupDeployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,19 @@ const core = require('@actions/core');

interface DeployerOptions {
deployerVersion?: string,
deployerRecipesVersion?: string,
skipDeployerInstall?: string,
}

const getInstalledDeployerMajorVersion = async (): Promise<number|null> => {
const {stdout} = await execa('composer', ['global', 'show', 'deployer/deployer']);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this will work correctly, since this is performed in an action, it won't e installed yet.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, dw I see this is done after install.


const regexp = /^versions.*?(\d+)/im;
const matches = regexp.exec(stdout);

return matches && +matches[1];
}

export default async (options: DeployerOptions): Promise<void> => {
if (options.skipDeployerInstall) return;

Expand All @@ -15,6 +25,16 @@ export default async (options: DeployerOptions): Promise<void> => {

await execa('composer', ['global', 'require', deployerPackage]);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're also going to need to install the correct deployer package. I think we should check the passed version string and then install only deployer if it's >= v7, otherwise install v6 + recipes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deployer version is checked after it is installed. Based on this, a decision is made to install recipes.
And now deployer latest version = 6 - recipies will be installed.
Deployer v7 will be installed without recipes.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is there will be breaking changes between the versions. We need to know what version the user is using, rather than what the latest is.


const deployerMajor = await getInstalledDeployerMajorVersion();

if (deployerMajor && deployerMajor <= 6) {
const deployerRecipesPackage = options.deployerRecipesVersion
? `deployer/recipes:${options.deployerRecipesVersion}`
: 'deployer/recipes';

await execa('composer', ['global', 'require', deployerRecipesPackage]);
}

const installPath = (await execa('composer', ['global', 'config', 'home'])).stdout;
core.addPath(`${installPath}/vendor/bin`);
};
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const tasks = new taskz([
text: 'Install Deployer',
task: () => SetupDeployer({
deployerVersion: core.getInput('deployer-version'),
deployerRecipesVersion: core.getInput('deployer-recipes-version'),
skipDeployerInstall: core.getInput('deployer-skip-install'),
})
},
Expand Down