├── .eslintrc.json ├── .github ├── dependabot.yml └── workflows │ ├── check-dist.yml │ ├── dependabot-build.yml │ ├── e2e.yml │ ├── screenshot.yml │ └── test.yml ├── .gitignore ├── .nvmrc ├── LICENSE ├── README.md ├── action.yml ├── dist ├── index.js └── src │ └── build │ └── Release │ └── DTraceProviderBindings.node ├── index.js ├── lib ├── load-inputs.js ├── logger.js ├── screenshot-website.js └── which-chrome.js ├── package-lock.json ├── package.json └── test └── index.test.js /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "node": true, 4 | "commonjs": true, 5 | "es6": true, 6 | "jest/globals": true 7 | }, 8 | "extends": "eslint:recommended", 9 | "globals": { 10 | "Atomics": "readonly", 11 | "SharedArrayBuffer": "readonly" 12 | }, 13 | "parserOptions": { 14 | "ecmaVersion": 2018 15 | }, 16 | "plugins": ["jest"], 17 | "rules": { 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: "weekly" 7 | 8 | - package-ecosystem: npm 9 | directory: "/" 10 | schedule: 11 | interval: "weekly" 12 | groups: 13 | dev-dependencies: 14 | dependency-type: "development" 15 | update-types: 16 | - "patch" 17 | - "minor" 18 | -------------------------------------------------------------------------------- /.github/workflows/check-dist.yml: -------------------------------------------------------------------------------- 1 | # This workflow helps ensure that generated innards of `dist` directory match what we expect them to be. 2 | # The `dist` is a particular directory in Actions that contains distributable JS files. 3 | # In Actions, the `dist` is generated through a build process from other source files. 4 | 5 | name: Check dist 6 | 7 | on: 8 | push: 9 | branches: 10 | - main 11 | paths-ignore: 12 | - '**.md' 13 | pull_request: 14 | paths-ignore: 15 | - '**.md' 16 | workflow_dispatch: 17 | 18 | jobs: 19 | check-dist-call: 20 | name: Check dist 21 | uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main 22 | with: 23 | node-version: "12.x" 24 | -------------------------------------------------------------------------------- /.github/workflows/dependabot-build.yml: -------------------------------------------------------------------------------- 1 | # Adatped from .github/workflows/dependabot-build.yml at https://github.com/github/dependabot-action 2 | 3 | name: Compile dependabot updates 4 | 5 | on: 6 | pull_request: 7 | 8 | permissions: 9 | pull-requests: write 10 | contents: write 11 | jobs: 12 | fetch-dependabot-metadata: 13 | runs-on: ubuntu-latest 14 | # We only want to check the metadata on pull_request events from Dependabot itself, 15 | # any subsequent pushes to the PR should just skip this step so we don't go into 16 | # a loop on commits created by the `build-dependabot-changes` job 17 | if: ${{ github.actor == 'dependabot[bot]' }} 18 | # Map the step output to a job output for subsequent jobs 19 | outputs: 20 | dependency-type: ${{ steps.dependabot-metadata.outputs.dependency-type }} 21 | package-ecosystem: ${{ steps.dependabot-metadata.outputs.package-ecosystem }} 22 | steps: 23 | - name: Fetch dependabot metadata 24 | id: dependabot-metadata 25 | uses: dependabot/fetch-metadata@c9c4182bf1b97f5224aee3906fd373f6b61b4526 # v1.6.0 26 | with: 27 | github-token: "${{ secrets.GITHUB_TOKEN }}" 28 | build-dependabot-changes: 29 | runs-on: ubuntu-latest 30 | needs: [fetch-dependabot-metadata] 31 | env: 32 | secret_dependabot_autobuild: ${{ secrets.DEPENDABOT_AUTOBUILD }} 33 | # We only need to build the dist/ folder if the PR relates to an npm dependency 34 | if: ${{ needs.fetch-dependabot-metadata.outputs.package-ecosystem == 'npm_and_yarn' }} 35 | steps: 36 | # Check out using a PAT so any pushed changes will trigger checkruns 37 | - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 38 | with: 39 | ref: ${{ github.event.pull_request.head.ref }} 40 | token: ${{ secrets.DEPENDABOT_AUTOBUILD }} 41 | 42 | - name: Read .nvmrc 43 | id: nvm 44 | run: echo "NVMRC=$(cat .nvmrc)" >> $GITHUB_OUTPUT 45 | 46 | - name: Setup Node.js 47 | uses: actions/setup-node@v3 48 | with: 49 | node-version: ${{ steps.nvm.outputs.NVMRC }} 50 | 51 | - name: Install npm dependencies 52 | run: npm clean-install 53 | 54 | - name: Rebuild the dist/ directory 55 | run: npm run package 56 | 57 | - name: Check in any change to dist/ 58 | if: ${{ env.secret_dependabot_autobuild != '' }} 59 | run: | 60 | git add dist/ 61 | # Specifying the full email allows the avatar to show up: https://github.com/orgs/community/discussions/26560 62 | git config user.name "github-actions[bot]" 63 | git config user.email "41898282+github-actions[bot]@users.noreply.github.com" 64 | git commit -m "[dependabot skip] Update dist/ with build changes" || exit 0 65 | git push 66 | -------------------------------------------------------------------------------- /.github/workflows/e2e.yml: -------------------------------------------------------------------------------- 1 | name: E2E 2 | 3 | on: 4 | push: 5 | branches: 6 | - v1.x 7 | workflow_dispatch: 8 | 9 | concurrency: 10 | group: ${{ github.workflow }}-${{ github.ref }} 11 | cancel-in-progress: true 12 | 13 | jobs: 14 | screenshot-ubuntu: 15 | name: Screenshot (Ubuntu) 16 | strategy: 17 | matrix: 18 | os: [ubuntu-latest] 19 | width: [1200, 992, 768, 600] 20 | runs-on: ${{ matrix.os }} 21 | 22 | steps: 23 | 24 | - name: Capture Screenshot 25 | id: screenshot 26 | uses: swinton/screenshot-website@v1.x 27 | with: 28 | source: https://github.com/swinton/screenshot-website 29 | destination: github-com-swinton-screenshot-website-${{ matrix.os }}-${{ matrix.width }}.png 30 | full-page: true 31 | width: ${{ matrix.width }} 32 | 33 | screenshot-macos: 34 | name: Screenshot (macOS) 35 | strategy: 36 | matrix: 37 | os: [macos-latest] 38 | width: [1200, 992, 768, 600] 39 | runs-on: ${{ matrix.os }} 40 | 41 | steps: 42 | 43 | - name: Capture Screenshot 44 | id: screenshot 45 | uses: swinton/screenshot-website@v1.x 46 | with: 47 | source: https://github.com/swinton/screenshot-website 48 | destination: github-com-swinton-screenshot-website-${{ matrix.os }}-${{ matrix.width }}.png 49 | full-page: true 50 | width: ${{ matrix.width }} 51 | 52 | screenshot-windows: 53 | name: Screenshot (Windows) 54 | strategy: 55 | matrix: 56 | os: [windows-latest] 57 | width: [1200, 992, 768, 600] 58 | runs-on: ${{ matrix.os }} 59 | 60 | steps: 61 | 62 | - name: Capture Screenshot 63 | id: screenshot 64 | uses: swinton/screenshot-website@v1.x 65 | with: 66 | source: https://github.com/swinton/screenshot-website 67 | destination: github-com-swinton-screenshot-website-${{ matrix.os }}-${{ matrix.width }}.png 68 | full-page: true 69 | width: ${{ matrix.width }} 70 | -------------------------------------------------------------------------------- /.github/workflows/screenshot.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | 3 | on: 4 | push: 5 | branches: 6 | - "main" 7 | pull_request: 8 | # Allows running this workflow manually from the Actions tab 9 | workflow_dispatch: 10 | 11 | concurrency: 12 | group: ${{ github.workflow }}-${{ github.ref }} 13 | cancel-in-progress: true 14 | 15 | jobs: 16 | screenshot-ubuntu: 17 | name: Screenshot (Ubuntu) 18 | strategy: 19 | matrix: 20 | os: [ubuntu-latest] 21 | width: [1200, 992, 768, 600] 22 | runs-on: ${{ matrix.os }} 23 | 24 | steps: 25 | 26 | - name: Checkout 27 | uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 28 | 29 | - name: Capture Screenshot 30 | id: screenshot 31 | uses: ./ 32 | with: 33 | source: https://github.com/swinton/screenshot-website 34 | destination: github-com-swinton-screenshot-website-${{ matrix.os }}-${{ matrix.width }}.png 35 | full-page: true 36 | width: ${{ matrix.width }} 37 | 38 | screenshot-macos: 39 | name: Screenshot (macOS) 40 | strategy: 41 | matrix: 42 | os: [macos-latest] 43 | width: [1200, 992, 768, 600] 44 | runs-on: ${{ matrix.os }} 45 | 46 | steps: 47 | 48 | - name: Checkout 49 | uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 50 | 51 | - name: Capture Screenshot 52 | id: screenshot 53 | uses: ./ 54 | with: 55 | source: https://github.com/swinton/screenshot-website 56 | destination: github-com-swinton-screenshot-website-${{ matrix.os }}-${{ matrix.width }}.png 57 | full-page: true 58 | width: ${{ matrix.width }} 59 | 60 | screenshot-windows: 61 | name: Screenshot (Windows) 62 | strategy: 63 | matrix: 64 | os: [windows-latest] 65 | width: [1200, 992, 768, 600] 66 | runs-on: ${{ matrix.os }} 67 | 68 | steps: 69 | 70 | - name: Checkout 71 | uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 72 | 73 | - name: Capture Screenshot 74 | id: screenshot 75 | uses: ./ 76 | with: 77 | source: https://github.com/swinton/screenshot-website 78 | destination: github-com-swinton-screenshot-website-${{ matrix.os }}-${{ matrix.width }}.png 79 | full-page: true 80 | width: ${{ matrix.width }} 81 | 82 | screenshot-no-width: 83 | name: Screenshot (no width) 84 | runs-on: ubuntu-latest 85 | 86 | steps: 87 | 88 | - name: Checkout 89 | uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 90 | 91 | - name: Capture Screenshot 92 | id: screenshot 93 | uses: ./ 94 | with: 95 | source: https://github.com/swinton/screenshot-website 96 | destination: github-com-swinton-screenshot-website-ubuntu-latest-default.png 97 | full-page: true 98 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: "Test" 2 | on: 3 | push: 4 | branches: 5 | - "main" 6 | - "v*" 7 | pull_request: 8 | 9 | concurrency: 10 | group: ${{ github.workflow }}-${{ github.ref }} 11 | cancel-in-progress: true 12 | 13 | jobs: 14 | test: 15 | strategy: 16 | matrix: 17 | os: [ubuntu-latest, macos-latest, windows-latest] 18 | runs-on: ${{ matrix.os }} 19 | steps: 20 | - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 21 | - uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8 # v3.7.0 22 | with: 23 | cache: npm 24 | node-version: 12.x 25 | - run: npm ci 26 | - run: npm test -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # TypeScript v1 declaration files 45 | typings/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | .env.test 74 | 75 | # parcel-bundler cache (https://parceljs.org/) 76 | .cache 77 | 78 | # Next.js build output 79 | .next 80 | 81 | # Nuxt.js build / generate output 82 | .nuxt 83 | 84 | # Gatsby files 85 | .cache/ 86 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 87 | # https://nextjs.org/blog/next-9-1#public-directory-support 88 | # public 89 | 90 | # vuepress build output 91 | .vuepress/dist 92 | 93 | # Serverless directories 94 | .serverless/ 95 | 96 | # FuseBox cache 97 | .fusebox/ 98 | 99 | # DynamoDB Local files 100 | .dynamodb/ 101 | 102 | # TernJS port file 103 | .tern-port 104 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | 12.22.12 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | ISC License 2 | 3 | Copyright (c) 2020, Steve Winton (https://github.com/swinton) 4 | 5 | Permission to use, copy, modify, and/or distribute this software for any 6 | purpose with or without fee is hereby granted, provided that the above 7 | copyright notice and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # :camera_flash: `screenshot-website` ![](https://github.com/swinton/screenshot-website/workflows/Tests/badge.svg) 2 | > A GitHub Action to capture screenshots of a website, across Windows, Mac, and Linux 3 | 4 | ## Contents 5 | - [Usage](#usage) 6 | - [Inputs](#inputs) 7 | - [Outputs](#outputs) 8 | - [Advanced Usage](#advanced-usage) 9 | - [Credits](#credits) 10 | 11 | ## Usage 12 | 13 | ```yaml 14 | - name: Screenshot Website 15 | uses: swinton/screenshot-website@v1.x 16 | with: 17 | source: https://github.com/swinton/screenshot-website 18 | destination: screenshot.png 19 | ``` 20 | 21 | ## Inputs 22 | 23 | ### Required inputs 24 | 25 | 1. `source`: Source of the content to be captured, may be a URL or HTML string, e.g. `https://example.com/` 26 | 1. `destination`: Destination filename the captured website will be written to, defaults to `screenshot.png` 27 | 28 | ### Optional inputs 29 | 30 | _Most_ of the options listed [here](https://github.com/sindresorhus/capture-website#options) (`inputType`, `width`, `height`, etc.) can be passed as inputs, just pass in a [kebab-cased](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles) equivalent, e.g. `full-page` for [`fullPage`](https://github.com/sindresorhus/capture-website#fullpage): 31 | 32 | ```yaml 33 | - name: Screenshot Website 34 | uses: swinton/screenshot-website@v1.x 35 | with: 36 | source: https://github.com/swinton/screenshot-website 37 | destination: screenshot.png 38 | full-page: true 39 | ``` 40 | 41 | ## Outputs 42 | 43 | An [artifact](https://help.github.com/en/actions/configuring-and-managing-workflows/persisting-workflow-data-using-artifacts) will be created automatically for each screenshot captured. The following additional outputs are also supported: 44 | 45 | 1. `path`: The filesystem path to the captured screenshot 46 | 47 | ## Advanced Usage 48 | 49 | Use a matrix to capture screenshots across different operating systems, e.g. 50 | 51 | ```yaml 52 | jobs: 53 | screenshot: 54 | name: Screenshot 55 | strategy: 56 | matrix: 57 | os: [ubuntu-latest, macos-latest, windows-latest] 58 | runs-on: ${{ matrix.os }} 59 | 60 | steps: 61 | 62 | - name: Screenshot Website 63 | uses: swinton/screenshot-website@v1.x 64 | with: 65 | source: https://github.com/swinton/screenshot-website 66 | destination: screenshot-${{ matrix.os }}.png 67 | ``` 68 | 69 | Combine a matrix with additional options such as width, e.g. 70 | 71 | ```yaml 72 | jobs: 73 | screenshot: 74 | name: Screenshot 75 | strategy: 76 | matrix: 77 | os: [ubuntu-latest, macos-latest, windows-latest] 78 | width: [1200, 992, 768, 600] 79 | runs-on: ${{ matrix.os }} 80 | 81 | steps: 82 | 83 | - name: Screenshot Website 84 | uses: swinton/screenshot-website@v1.x 85 | with: 86 | source: https://github.com/swinton/screenshot-website 87 | destination: screenshot-${{ matrix.os }}-${{ matrix.width }}.png 88 | width: ${{ matrix.width }} 89 | ``` 90 | 91 | 92 | ## Credits 93 | 94 | - :bow: https://github.com/sindresorhus/capture-website 95 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'screenshot-website' 2 | description: 'Capture screenshot of a website' 3 | inputs: 4 | source: 5 | description: 'Source of the content to be captured, may be a URL or HTML content' 6 | required: true 7 | destination: 8 | description: 'The destination filename the captured website will be written to' 9 | required: false 10 | default: 'screenshot.png' 11 | delay: 12 | description: 'The number of seconds to wait after the page finished loading before capturing the screenshot' 13 | required: false 14 | default: '0' 15 | full-page: 16 | description: 'Capture the full scrollable page, not just the viewport' 17 | required: false 18 | default: 'false' 19 | width: 20 | description: 'Page width' 21 | required: false 22 | default: '1280' 23 | outputs: 24 | path: 25 | description: 'The filesystem path to the website screenshot' 26 | runs: 27 | using: 'node12' 28 | main: 'dist/index.js' 29 | branding: 30 | icon: 'camera' 31 | color: 'purple' 32 | -------------------------------------------------------------------------------- /dist/src/build/Release/DTraceProviderBindings.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swinton/screenshot-website/e51cdb7268022e0d120994461461e6240866178f/dist/src/build/Release/DTraceProviderBindings.node -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const run = require('./lib/screenshot-website'); 2 | 3 | run(); -------------------------------------------------------------------------------- /lib/load-inputs.js: -------------------------------------------------------------------------------- 1 | const yaml = require("js-yaml"); 2 | 3 | function normalizeInputName(inputName) { 4 | const chars = inputName.toLowerCase().split(''); 5 | let normalized = ''; 6 | 7 | for (let i = 0; i < chars.length; i++) { 8 | const char = chars[i]; 9 | const prevChar = i > 0 ? chars[i-1] : ''; 10 | if (char !== '-') { 11 | if (prevChar === '-') { 12 | normalized += char.toUpperCase(); 13 | } else { 14 | normalized += char; 15 | } 16 | } 17 | } 18 | return normalized; 19 | } 20 | 21 | function normalizeInputValue(inputName, inputValue) { 22 | return yaml.load(inputValue); 23 | } 24 | 25 | // Thank you, octokit/request-action :bow: 26 | // https://github.com/octokit/request-action/blob/a43ad662a5c7b9f83ff18ff5d40564f214c23925/index.js#L41-L52 27 | function loadInputs() { 28 | return Object.entries(process.env).reduce((result, [key, value]) => { 29 | if (!/^INPUT_/.test(key)) return result; 30 | 31 | const inputName = normalizeInputName(key.substr("INPUT_".length)); 32 | 33 | result[inputName] = normalizeInputValue(inputName, value); 34 | 35 | return result; 36 | }, {}); 37 | } 38 | 39 | module.exports = loadInputs; 40 | -------------------------------------------------------------------------------- /lib/logger.js: -------------------------------------------------------------------------------- 1 | const Logger = require('bunyan'); 2 | const bunyanFormat = require('bunyan-format'); 3 | const { name } = require('../package'); 4 | 5 | const logger = new Logger({ 6 | name, 7 | level: process.env.LOG_LEVEL || 'info', 8 | stream: bunyanFormat({ outputMode: process.env.LOG_FORMAT || 'short' }, process.stderr) 9 | }); 10 | 11 | module.exports = logger; 12 | -------------------------------------------------------------------------------- /lib/screenshot-website.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const captureWebsite = require('capture-website'); 3 | const core = require('@actions/core'); 4 | const artifact = require('@actions/artifact'); 5 | const loadInputs = require('./load-inputs'); 6 | const whichChrome = require('./which-chrome'); 7 | 8 | async function run() { 9 | try { 10 | // Get inputs: source, destination, and anything else 11 | const { source, destination: destFile, ...inputs } = loadInputs(); 12 | core.debug(`source is ${source}`); 13 | core.debug(`destination is ${destFile}`); 14 | core.debug(`other inputs are ${JSON.stringify(inputs, null, 4)}`); 15 | 16 | // Get destination 17 | const destFolder = process.env.RUNNER_TEMP; 18 | const dest = path.join(destFolder, destFile); 19 | 20 | // Locate Google Chrome executable 21 | const executablePath = await whichChrome(); 22 | core.debug(`executablePath is ${executablePath}`); 23 | 24 | // Options for capture 25 | const options = { 26 | launchOptions: { 27 | executablePath 28 | }, 29 | ...inputs 30 | }; 31 | 32 | // Capture and write to dest 33 | await captureWebsite.file(source, dest, options); 34 | 35 | // Create an artifact 36 | const artifactClient = artifact.create(); 37 | const artifactName = destFile.substr(0, destFile.lastIndexOf('.')); 38 | await artifactClient.uploadArtifact(artifactName, [dest], destFolder); 39 | 40 | // Expose the path to the screenshot as an output 41 | core.setOutput('path', dest); 42 | } catch (error) { 43 | core.setFailed(error.message); 44 | } 45 | } 46 | 47 | module.exports = run; -------------------------------------------------------------------------------- /lib/which-chrome.js: -------------------------------------------------------------------------------- 1 | async function whichChrome() { 2 | // Locate Google Chrome executable 3 | // "google-chrome" on Linux 4 | // "chrome.exe" on Windows 5 | // "Google Chrome" on macOSs 6 | const executables = { 7 | Linux: '/usr/bin/google-chrome', 8 | Windows: 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe', 9 | macOS: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', 10 | }; 11 | 12 | return executables[process.env.RUNNER_OS]; 13 | } 14 | 15 | module.exports = whichChrome; 16 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "screenshot-url", 3 | "version": "1.0.1", 4 | "description": "", 5 | "author": "Steve Winton (https://github.com/swinton)", 6 | "main": "index.js", 7 | "license": "ISC", 8 | "keywords": [], 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/swinton/screenshot-url.git" 12 | }, 13 | "scripts": { 14 | "start": "node ./index.js", 15 | "dev": "nodemon", 16 | "test": "jest && eslint {index.js,lib/**/*.js,test/**/*.js}", 17 | "lint": "eslint index.js {index.js,lib/**/*.js,test/**/*.js} --fix", 18 | "build": "npm run package", 19 | "package": "ncc build index.js -o dist", 20 | "pre-commit": "npm run package && git add dist/index.js" 21 | }, 22 | "dependencies": { 23 | "@actions/artifact": "^0.1.0", 24 | "@actions/core": "^1.10.0", 25 | "bunyan": "^1.8.12", 26 | "bunyan-format": "^0.2.1", 27 | "capture-website": "^0.8.1", 28 | "dotenv": "^16.3.1", 29 | "js-yaml": "^4.1.0", 30 | "puppeteer": "^13.7.0" 31 | }, 32 | "devDependencies": { 33 | "@zeit/ncc": "^0.22.3", 34 | "eslint": "^8.47.0", 35 | "eslint-config-airbnb": "^19.0.4", 36 | "eslint-config-prettier": "^9.0.0", 37 | "eslint-plugin-import": "^2.28.0", 38 | "eslint-plugin-jest": "^26.9.0", 39 | "eslint-plugin-jsx-a11y": "^6.7.1", 40 | "eslint-plugin-prettier": "^5.0.0", 41 | "eslint-plugin-react": "^7.33.1", 42 | "husky": "^8.0.3", 43 | "jest": "^28.1.3", 44 | "nodemon": "^3.0.1", 45 | "prettier": "^3.0.1" 46 | }, 47 | "engines": { 48 | "node": ">= 8.3.0" 49 | }, 50 | "jest": { 51 | "testEnvironment": "node", 52 | "collectCoverageFrom": [ 53 | "index.js", 54 | "lib/*.js" 55 | ], 56 | "coverageThreshold": { 57 | "global": { 58 | "branches": 80, 59 | "functions": 80, 60 | "lines": 80, 61 | "statements": 80 62 | } 63 | } 64 | }, 65 | "nodemonConfig": { 66 | "exec": "npm start", 67 | "watch": [ 68 | ".env", 69 | "." 70 | ] 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /test/index.test.js: -------------------------------------------------------------------------------- 1 | test('that we can run tests', () => { 2 | // your real tests go here 3 | expect(1 + 2 + 3).toBe(6); 4 | }); 5 | --------------------------------------------------------------------------------