Skip to content

Commit

Permalink
Use our standard eslint/prettier setup
Browse files Browse the repository at this point in the history
Also fixes a test causing an unhandled promise rejection
  • Loading branch information
brew committed Jun 3, 2021
1 parent d541831 commit 51dc8f1
Show file tree
Hide file tree
Showing 9 changed files with 1,370 additions and 718 deletions.
24 changes: 0 additions & 24 deletions .eslintrc

This file was deleted.

23 changes: 23 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = {
root: true,
env: {
node: true,
jest: true,
},
extends: [
'standard',
'plugin:node/recommended',
'plugin:prettier/recommended',
],
plugins: ['prettier'],
globals: {
fetch: true,
},
rules: {
'generator-star-spacing': 'off',
'space-before-function-paren': 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'prettier/prettier': 'error',
'node/no-unpublished-require': 0,
},
};
8 changes: 8 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
semi: true,
bracketSpacing: true,
jsxBracketSameLine: true,
singleQuote: true,
trailingComma: 'all',
arrowParens: 'avoid',
};
23 changes: 15 additions & 8 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,8 @@ const isReleaseTag = ref => ref && ref.includes('refs/tags/release/');

const isMasterBranch = ref => ref && ref === 'refs/heads/master';

const isNotMasterBranch = ref => ref && ref.includes('refs/heads/') && ref !== 'refs/heads/master';
const isNotMasterBranch = ref =>
ref && ref.includes('refs/heads/') && ref !== 'refs/heads/master';

const createBuildCommand = (dockerfile, imageName, target, buildArgs) => {
let buildCommandPrefix = `docker build -f ${dockerfile} -t ${imageName}`;
Expand Down Expand Up @@ -575,11 +576,13 @@ const createTag = () => {
// If we're on a non-master branch, use branch-prefix-{GIT_SHORT_SHA) as the Docker tag
// refs/heads/jira-123/feature/something
const branchName = ref.replace('refs/heads/', '');
const branchPrefix = branchName.includes('/') ? branchName.substring(0, branchName.indexOf('/')) : branchName;
const branchPrefix = branchName.includes('/')
? branchName.substring(0, branchName.indexOf('/'))
: branchName;
dockerTag = `${branchPrefix}-${shortSha}`;
} else {
core.setFailed(
'Unsupported GitHub event - only supports push https://help.github.com/en/articles/events-that-trigger-workflows#push-event-push'
'Unsupported GitHub event - only supports push https://help.github.com/en/articles/events-that-trigger-workflows#push-event-push',
);
}

Expand All @@ -597,13 +600,17 @@ const build = (imageName, target, buildArgs) => {
core.info(`Building Docker image: ${imageName}`);
cp.execSync(createBuildCommand(dockerfile, imageName, target, buildArgs), {
maxBuffer: maxBufferSize,
stdio: 'inherit'
stdio: 'inherit',
});
};

const isEcr = registry => registry && registry.includes('amazonaws');

const getRegion = registry => registry.substring(registry.indexOf('ecr.') + 4, registry.indexOf('.amazonaws'));
const getRegion = registry =>
registry.substring(
registry.indexOf('ecr.') + 4,
registry.indexOf('.amazonaws'),
);

const login = () => {
const registry = core.getInput('registry', { required: true });
Expand All @@ -615,12 +622,12 @@ const login = () => {
const region = getRegion(registry);
core.info(`Logging into ECR region ${region}...`);
cp.execSync(
`aws ecr get-login-password --region ${region} | docker login --username AWS --password-stdin ${registry}`
`aws ecr get-login-password --region ${region} | docker login --username AWS --password-stdin ${registry}`,
);
} else if (username && password) {
core.info(`Logging into Docker registry ${registry}...`);
cp.execSync(`docker login -u ${username} --password-stdin ${registry}`, {
input: password
input: password,
});
}
};
Expand All @@ -634,7 +641,7 @@ module.exports = {
createTag,
build,
login,
push
push,
};


Expand Down
Loading

0 comments on commit 51dc8f1

Please sign in to comment.