Skip to content

Commit

Permalink
feat: 🎸 added new features
Browse files Browse the repository at this point in the history
  • Loading branch information
ADMSK\AVROGAL1 committed Feb 20, 2021
1 parent 3476300 commit 0056dae
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 19 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/versioning.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#########################
#########################
## Version GitHub Tags ##
#########################
#########################

#
# Documentation:
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
#

##########################
# Name of the action job #
##########################
name: Keep GitHub tag versions up-to-date

#####################################################
# Run the job when a release is published or edited #
#####################################################
on:
release:
types: [ published, edited ]

#################
# Start the job #
#################
jobs:
actions-tagger:
runs-on: windows-latest
steps:
#############################
# Check out the latest code #
#############################
- uses: actions/[email protected]

######################
# Run the tag action #
######################
- uses: Actions-R-Us/[email protected]
with:
publish_latest_tag: true
env:
GITHUB_TOKEN: "${{secrets.GITHUB_TOKEN}}"
2 changes: 1 addition & 1 deletion dist/index.js

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

36 changes: 18 additions & 18 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,25 @@ const config = require('./src/config');
const { notBlankOrElse } = require('./src/utils');

async function createSnapshot(url, filePath, fileName, fileExtension) {
try {
const imagePath = path.join(filePath, `${fileName}.${fileExtension}`);
console.log(`
const imagePath = path.join(filePath, `${fileName}.${fileExtension}`);
console.log(`
Generating screenshot with parameters: url=${url}, file=${imagePath}
`);

if (!fs.existsSync(filePath)) {
fs.mkdirSync(filePath);
}
if (!fs.existsSync(filePath)) {
fs.mkdirSync(filePath);
}

const image = fs.createWriteStream(imagePath);
await http.get(url, resp => {
resp.pipe(image);
});
const image = fs.createWriteStream(imagePath);
await http.get(url, resp => {
resp.pipe(image);
});

return imagePath;
} catch (e) {
console.error(e);
}
return imagePath;
}

async function run() {
const url = core.getInput('url');
const url = core.getInput('url', { required: true });
const width = notBlankOrElse(core.getInput('width'), config.width);
const height = notBlankOrElse(core.getInput('height'), config.height);
const fullPage = notBlankOrElse(core.getInput('fullPage'), config.fullPage);
Expand All @@ -43,9 +39,13 @@ async function run() {

const target = `${config.url}?url=${url}&width=${width}&height=${height}&fullPage=${fullPage}&encoding=${encoding}&type=${fileExtension}`;

const imagePath = await createSnapshot(target, filePath, fileName, fileExtension);

core.setOutput('image', imagePath);
try {
const imagePath = await createSnapshot(target, filePath, fileName, fileExtension);
core.info(`Storing screenshot image by path: ${imagePath}`);
core.setOutput('image', imagePath);
} catch (e) {
core.setFailed(`Cannot create screenshot image by path: ${filePath}/${fileName}, message: ${e.message}`);
}
}

module.exports = run;
Expand Down

0 comments on commit 0056dae

Please sign in to comment.