├── .env ├── .github └── workflows │ └── main.yml ├── .gitignore ├── .nvmrc ├── .prettierrc.json ├── .vscode └── launch.json ├── LICENSE ├── README.md ├── action.yml ├── dist ├── index.js └── main.js ├── package-lock.json ├── package.json ├── sample ├── demo.md └── sample2 │ └── demo2.md ├── src └── main.ts └── tsconfig.json /.env: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aTable/deploy-to-dropbox/5ad0fe18ffeb7037f45b3daa3d10da63d9cef372/.env -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | on: [push] 2 | 3 | jobs: 4 | local_development: 5 | runs-on: ubuntu-latest 6 | name: Testing action 7 | steps: 8 | - name: Checkout 9 | uses: actions/checkout@v2 10 | - name: Execute my action 11 | uses: ./ # Uses an action in the root directory 12 | with: 13 | DROPBOX_ACCESS_TOKEN: ${{ secrets.DROPBOX_ACCESS_TOKEN }} 14 | DROPBOX_DESTINATION_PATH_PREFIX: "/" 15 | GLOB: "sample/**/*.md" 16 | DEBUG: false 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .env 3 | build -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | v13.10.1 -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 80, 3 | "tabWidth": 2, 4 | "useTabs": false, 5 | "semi": false, 6 | "singleQuote": true, 7 | "trailingComma": "all", 8 | "bracketSpacing": false, 9 | "arrowParens": "always", 10 | "parser": "typescript" 11 | } 12 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "pwa-node", 9 | "request": "launch", 10 | "name": "Launch Program", 11 | "skipFiles": ["/**"], 12 | "program": "${workspaceFolder}/dist/index.js", 13 | "preLaunchTask": "tsc: build - tsconfig.json", 14 | "outFiles": ["${workspaceFolder}/dist/**/*.js"], 15 | "envFile": "${workspaceFolder}/.env" 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 aTable 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # deploy-to-dropbox 2 | 3 | A GitHub Action to deploy to Dropbox 4 | 5 | ## Initialisation 6 | 7 | Follow [this guide](https://preventdirectaccess.com/docs/create-app-key-access-token-for-dropbox-account/#access-token) to create and get your access token 8 | 9 | Save the token to your repository `Settings > Secrets`: 10 | 11 | - Name: `DROPBOX_ACCESS_TOKEN` 12 | - Value: `YOUR_TOKEN_FROM_DROPBOX_APP_CONSOLE` 13 | 14 | 15 | ## Developing 16 | 17 | For the lazy ... 18 | ```bash 19 | git add -A && git commit -m "ci" && git tag -a -m "ci" v1.0.5 && git push --follow-tags 20 | ``` -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'Deploy to Dropbox' 2 | description: 'This action will handle the deployment process of your project to Dropbox.' 3 | author: 'aTable' 4 | branding: 5 | icon: 'upload-cloud' 6 | color: 'black' 7 | runs: 8 | using: 'node12' 9 | main: 'dist/index.js' 10 | inputs: 11 | DROPBOX_ACCESS_TOKEN: 12 | description: 'Value should be a secret that is set in your repository settings' 13 | required: true 14 | 15 | GLOB: 16 | description: 'Glob that you want to save to Dropbox e.g dir1/dir2/**/*.md or **/*.txt' 17 | required: true 18 | 19 | DROPBOX_DESTINATION_PATH_PREFIX: 20 | description: 'The destination path prefix to save to in Dropbox. This will prepend the individual globs. Default value is "/"' 21 | required: false 22 | default: "/" 23 | 24 | DEBUG: 25 | description: "Enable debugging." 26 | required: false 27 | 28 | -------------------------------------------------------------------------------- /dist/main.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var Dropbox = require('dropbox').Dropbox; 3 | var fs = require('fs'); 4 | var fetch2 = require('node-fetch'); 5 | var core = require('@actions/core'); 6 | var github = require('@actions/github'); 7 | var glob = require('glob'); 8 | var accessToken = core.getInput('DROPBOX_ACCESS_TOKEN'); 9 | var globSource = core.getInput('GLOB'); 10 | var dropboxPathPrefix = core.getInput('DROPBOX_DESTINATION_PATH_PREFIX'); 11 | var isDebug = core.getInput('DEBUG'); 12 | var dropbox = new Dropbox({ accessToken: accessToken, fetch: fetch2 }); 13 | function uploadMuhFile(filePath) { 14 | var file = fs.readFileSync(filePath); 15 | var destinationPath = "" + dropboxPathPrefix + filePath; 16 | if (isDebug) 17 | console.log('uploaded file to Dropbox at: ', destinationPath); 18 | return dropbox 19 | .filesUpload({ path: destinationPath, contents: file }) 20 | .then(function (response) { 21 | if (isDebug) 22 | console.log(response); 23 | return response; 24 | }) 25 | .catch(function (error) { 26 | if (isDebug) 27 | console.error(error); 28 | return error; 29 | }); 30 | } 31 | glob(globSource, {}, function (err, files) { 32 | if (err) 33 | core.setFailed('Error: glob failed', err); 34 | Promise.all(files.map(uploadMuhFile)) 35 | .then(function (all) { 36 | console.log('all files uploaded', all); 37 | }) 38 | .catch(function (err) { 39 | console.error('error', err); 40 | }); 41 | }); 42 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "deploy-to-dropbox", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@actions/core": { 8 | "version": "1.9.1", 9 | "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.9.1.tgz", 10 | "integrity": "sha512-5ad+U2YGrmmiw6du20AQW5XuWo7UKN2052FjSV7MX+Wfjf8sCqcsZe62NfgHys4QI4/Y+vQvLKYL8jWtA1ZBTA==", 11 | "requires": { 12 | "@actions/http-client": "^2.0.1", 13 | "uuid": "^8.3.2" 14 | }, 15 | "dependencies": { 16 | "@actions/http-client": { 17 | "version": "2.0.1", 18 | "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz", 19 | "integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==", 20 | "requires": { 21 | "tunnel": "^0.0.6" 22 | } 23 | } 24 | } 25 | }, 26 | "@actions/github": { 27 | "version": "2.1.1", 28 | "resolved": "https://registry.npmjs.org/@actions/github/-/github-2.1.1.tgz", 29 | "integrity": "sha512-kAgTGUx7yf5KQCndVeHSwCNZuDBvPyxm5xKTswW2lofugeuC1AZX73nUUVDNaysnM9aKFMHv9YCdVJbg7syEyA==", 30 | "requires": { 31 | "@actions/http-client": "^1.0.3", 32 | "@octokit/graphql": "^4.3.1", 33 | "@octokit/rest": "^16.43.1" 34 | } 35 | }, 36 | "@actions/http-client": { 37 | "version": "1.0.8", 38 | "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.8.tgz", 39 | "integrity": "sha512-G4JjJ6f9Hb3Zvejj+ewLLKLf99ZC+9v+yCxoYf9vSyH+WkzPLB2LuUtRMGNkooMqdugGBFStIKXOuvH1W+EctA==", 40 | "requires": { 41 | "tunnel": "0.0.6" 42 | } 43 | }, 44 | "@octokit/auth-token": { 45 | "version": "2.4.0", 46 | "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-2.4.0.tgz", 47 | "integrity": "sha512-eoOVMjILna7FVQf96iWc3+ZtE/ZT6y8ob8ZzcqKY1ibSQCnu4O/B7pJvzMx5cyZ/RjAff6DAdEb0O0Cjcxidkg==", 48 | "requires": { 49 | "@octokit/types": "^2.0.0" 50 | } 51 | }, 52 | "@octokit/endpoint": { 53 | "version": "5.5.3", 54 | "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-5.5.3.tgz", 55 | "integrity": "sha512-EzKwkwcxeegYYah5ukEeAI/gYRLv2Y9U5PpIsseGSFDk+G3RbipQGBs8GuYS1TLCtQaqoO66+aQGtITPalxsNQ==", 56 | "requires": { 57 | "@octokit/types": "^2.0.0", 58 | "is-plain-object": "^3.0.0", 59 | "universal-user-agent": "^5.0.0" 60 | }, 61 | "dependencies": { 62 | "universal-user-agent": { 63 | "version": "5.0.0", 64 | "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-5.0.0.tgz", 65 | "integrity": "sha512-B5TPtzZleXyPrUMKCpEHFmVhMN6EhmJYjG5PQna9s7mXeSqGTLap4OpqLl5FCEFUI3UBmllkETwKf/db66Y54Q==", 66 | "requires": { 67 | "os-name": "^3.1.0" 68 | } 69 | } 70 | } 71 | }, 72 | "@octokit/graphql": { 73 | "version": "4.3.1", 74 | "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-4.3.1.tgz", 75 | "integrity": "sha512-hCdTjfvrK+ilU2keAdqNBWOk+gm1kai1ZcdjRfB30oA3/T6n53UVJb7w0L5cR3/rhU91xT3HSqCd+qbvH06yxA==", 76 | "requires": { 77 | "@octokit/request": "^5.3.0", 78 | "@octokit/types": "^2.0.0", 79 | "universal-user-agent": "^4.0.0" 80 | } 81 | }, 82 | "@octokit/plugin-paginate-rest": { 83 | "version": "1.1.2", 84 | "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-1.1.2.tgz", 85 | "integrity": "sha512-jbsSoi5Q1pj63sC16XIUboklNw+8tL9VOnJsWycWYR78TKss5PVpIPb1TUUcMQ+bBh7cY579cVAWmf5qG+dw+Q==", 86 | "requires": { 87 | "@octokit/types": "^2.0.1" 88 | } 89 | }, 90 | "@octokit/plugin-request-log": { 91 | "version": "1.0.0", 92 | "resolved": "https://registry.npmjs.org/@octokit/plugin-request-log/-/plugin-request-log-1.0.0.tgz", 93 | "integrity": "sha512-ywoxP68aOT3zHCLgWZgwUJatiENeHE7xJzYjfz8WI0goynp96wETBF+d95b8g/uL4QmS6owPVlaxiz3wyMAzcw==" 94 | }, 95 | "@octokit/plugin-rest-endpoint-methods": { 96 | "version": "2.4.0", 97 | "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-2.4.0.tgz", 98 | "integrity": "sha512-EZi/AWhtkdfAYi01obpX0DF7U6b1VRr30QNQ5xSFPITMdLSfhcBqjamE3F+sKcxPbD7eZuMHu3Qkk2V+JGxBDQ==", 99 | "requires": { 100 | "@octokit/types": "^2.0.1", 101 | "deprecation": "^2.3.1" 102 | } 103 | }, 104 | "@octokit/request": { 105 | "version": "5.3.2", 106 | "resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.3.2.tgz", 107 | "integrity": "sha512-7NPJpg19wVQy1cs2xqXjjRq/RmtSomja/VSWnptfYwuBxLdbYh2UjhGi0Wx7B1v5Iw5GKhfFDQL7jM7SSp7K2g==", 108 | "requires": { 109 | "@octokit/endpoint": "^5.5.0", 110 | "@octokit/request-error": "^1.0.1", 111 | "@octokit/types": "^2.0.0", 112 | "deprecation": "^2.0.0", 113 | "is-plain-object": "^3.0.0", 114 | "node-fetch": "^2.3.0", 115 | "once": "^1.4.0", 116 | "universal-user-agent": "^5.0.0" 117 | }, 118 | "dependencies": { 119 | "universal-user-agent": { 120 | "version": "5.0.0", 121 | "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-5.0.0.tgz", 122 | "integrity": "sha512-B5TPtzZleXyPrUMKCpEHFmVhMN6EhmJYjG5PQna9s7mXeSqGTLap4OpqLl5FCEFUI3UBmllkETwKf/db66Y54Q==", 123 | "requires": { 124 | "os-name": "^3.1.0" 125 | } 126 | } 127 | } 128 | }, 129 | "@octokit/request-error": { 130 | "version": "1.2.1", 131 | "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-1.2.1.tgz", 132 | "integrity": "sha512-+6yDyk1EES6WK+l3viRDElw96MvwfJxCt45GvmjDUKWjYIb3PJZQkq3i46TwGwoPD4h8NmTrENmtyA1FwbmhRA==", 133 | "requires": { 134 | "@octokit/types": "^2.0.0", 135 | "deprecation": "^2.0.0", 136 | "once": "^1.4.0" 137 | } 138 | }, 139 | "@octokit/rest": { 140 | "version": "16.43.1", 141 | "resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-16.43.1.tgz", 142 | "integrity": "sha512-gfFKwRT/wFxq5qlNjnW2dh+qh74XgTQ2B179UX5K1HYCluioWj8Ndbgqw2PVqa1NnVJkGHp2ovMpVn/DImlmkw==", 143 | "requires": { 144 | "@octokit/auth-token": "^2.4.0", 145 | "@octokit/plugin-paginate-rest": "^1.1.1", 146 | "@octokit/plugin-request-log": "^1.0.0", 147 | "@octokit/plugin-rest-endpoint-methods": "2.4.0", 148 | "@octokit/request": "^5.2.0", 149 | "@octokit/request-error": "^1.0.2", 150 | "atob-lite": "^2.0.0", 151 | "before-after-hook": "^2.0.0", 152 | "btoa-lite": "^1.0.0", 153 | "deprecation": "^2.0.0", 154 | "lodash.get": "^4.4.2", 155 | "lodash.set": "^4.3.2", 156 | "lodash.uniq": "^4.5.0", 157 | "octokit-pagination-methods": "^1.1.0", 158 | "once": "^1.4.0", 159 | "universal-user-agent": "^4.0.0" 160 | } 161 | }, 162 | "@octokit/types": { 163 | "version": "2.5.0", 164 | "resolved": "https://registry.npmjs.org/@octokit/types/-/types-2.5.0.tgz", 165 | "integrity": "sha512-KEnLwOfdXzxPNL34fj508bhi9Z9cStyN7qY1kOfVahmqtAfrWw6Oq3P4R+dtsg0lYtZdWBpUrS/Ixmd5YILSww==", 166 | "requires": { 167 | "@types/node": ">= 8" 168 | } 169 | }, 170 | "@types/node": { 171 | "version": "13.9.3", 172 | "resolved": "https://registry.npmjs.org/@types/node/-/node-13.9.3.tgz", 173 | "integrity": "sha512-01s+ac4qerwd6RHD+mVbOEsraDHSgUaefQlEdBbUolnQFjKwCr7luvAlEwW1RFojh67u0z4OUTjPn9LEl4zIkA==" 174 | }, 175 | "@zeit/ncc": { 176 | "version": "0.22.0", 177 | "resolved": "https://registry.npmjs.org/@zeit/ncc/-/ncc-0.22.0.tgz", 178 | "integrity": "sha512-zaS6chwztGSLSEzsTJw9sLTYxQt57bPFBtsYlVtbqGvmDUsfW7xgXPYofzFa1kB9ur2dRop6IxCwPnWLBVCrbQ==", 179 | "dev": true 180 | }, 181 | "atob-lite": { 182 | "version": "2.0.0", 183 | "resolved": "https://registry.npmjs.org/atob-lite/-/atob-lite-2.0.0.tgz", 184 | "integrity": "sha1-D+9a1G8b16hQLGVyfwNn1e5D1pY=" 185 | }, 186 | "balanced-match": { 187 | "version": "1.0.0", 188 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", 189 | "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" 190 | }, 191 | "base64-js": { 192 | "version": "1.3.1", 193 | "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz", 194 | "integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==" 195 | }, 196 | "before-after-hook": { 197 | "version": "2.1.0", 198 | "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.1.0.tgz", 199 | "integrity": "sha512-IWIbu7pMqyw3EAJHzzHbWa85b6oud/yfKYg5rqB5hNE8CeMi3nX+2C2sj0HswfblST86hpVEOAb9x34NZd6P7A==" 200 | }, 201 | "brace-expansion": { 202 | "version": "1.1.11", 203 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", 204 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", 205 | "requires": { 206 | "balanced-match": "^1.0.0", 207 | "concat-map": "0.0.1" 208 | } 209 | }, 210 | "btoa-lite": { 211 | "version": "1.0.0", 212 | "resolved": "https://registry.npmjs.org/btoa-lite/-/btoa-lite-1.0.0.tgz", 213 | "integrity": "sha1-M3dm2hWAEhD92VbCLpxokaudAzc=" 214 | }, 215 | "buffer": { 216 | "version": "5.5.0", 217 | "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.5.0.tgz", 218 | "integrity": "sha512-9FTEDjLjwoAkEwyMGDjYJQN2gfRgOKBKRfiglhvibGbpeeU/pQn1bJxQqm32OD/AIeEuHxU9roxXxg34Byp/Ww==", 219 | "requires": { 220 | "base64-js": "^1.0.2", 221 | "ieee754": "^1.1.4" 222 | } 223 | }, 224 | "concat-map": { 225 | "version": "0.0.1", 226 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 227 | "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" 228 | }, 229 | "cross-spawn": { 230 | "version": "6.0.5", 231 | "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", 232 | "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", 233 | "requires": { 234 | "nice-try": "^1.0.4", 235 | "path-key": "^2.0.1", 236 | "semver": "^5.5.0", 237 | "shebang-command": "^1.2.0", 238 | "which": "^1.2.9" 239 | } 240 | }, 241 | "deprecation": { 242 | "version": "2.3.1", 243 | "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", 244 | "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==" 245 | }, 246 | "dropbox": { 247 | "version": "4.0.30", 248 | "resolved": "https://registry.npmjs.org/dropbox/-/dropbox-4.0.30.tgz", 249 | "integrity": "sha512-qmSeT8rhjARDHj3vxOTKQjc6IQ46AlRwJS8dqE26R323fikkjC4EXzocV12PsO7DOrjaqbOH3FjEdEEnrFraJw==", 250 | "requires": { 251 | "buffer": "^5.0.8", 252 | "moment": "^2.19.3" 253 | } 254 | }, 255 | "end-of-stream": { 256 | "version": "1.4.4", 257 | "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", 258 | "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", 259 | "requires": { 260 | "once": "^1.4.0" 261 | } 262 | }, 263 | "execa": { 264 | "version": "1.0.0", 265 | "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz", 266 | "integrity": "sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==", 267 | "requires": { 268 | "cross-spawn": "^6.0.0", 269 | "get-stream": "^4.0.0", 270 | "is-stream": "^1.1.0", 271 | "npm-run-path": "^2.0.0", 272 | "p-finally": "^1.0.0", 273 | "signal-exit": "^3.0.0", 274 | "strip-eof": "^1.0.0" 275 | } 276 | }, 277 | "fs.realpath": { 278 | "version": "1.0.0", 279 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", 280 | "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" 281 | }, 282 | "get-stream": { 283 | "version": "4.1.0", 284 | "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", 285 | "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", 286 | "requires": { 287 | "pump": "^3.0.0" 288 | } 289 | }, 290 | "glob": { 291 | "version": "7.1.6", 292 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", 293 | "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", 294 | "requires": { 295 | "fs.realpath": "^1.0.0", 296 | "inflight": "^1.0.4", 297 | "inherits": "2", 298 | "minimatch": "^3.0.4", 299 | "once": "^1.3.0", 300 | "path-is-absolute": "^1.0.0" 301 | } 302 | }, 303 | "ieee754": { 304 | "version": "1.1.13", 305 | "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", 306 | "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==" 307 | }, 308 | "inflight": { 309 | "version": "1.0.6", 310 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", 311 | "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", 312 | "requires": { 313 | "once": "^1.3.0", 314 | "wrappy": "1" 315 | } 316 | }, 317 | "inherits": { 318 | "version": "2.0.4", 319 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", 320 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" 321 | }, 322 | "is-plain-object": { 323 | "version": "3.0.0", 324 | "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-3.0.0.tgz", 325 | "integrity": "sha512-tZIpofR+P05k8Aocp7UI/2UTa9lTJSebCXpFFoR9aibpokDj/uXBsJ8luUu0tTVYKkMU6URDUuOfJZ7koewXvg==", 326 | "requires": { 327 | "isobject": "^4.0.0" 328 | } 329 | }, 330 | "is-stream": { 331 | "version": "1.1.0", 332 | "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", 333 | "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" 334 | }, 335 | "isexe": { 336 | "version": "2.0.0", 337 | "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", 338 | "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" 339 | }, 340 | "isobject": { 341 | "version": "4.0.0", 342 | "resolved": "https://registry.npmjs.org/isobject/-/isobject-4.0.0.tgz", 343 | "integrity": "sha512-S/2fF5wH8SJA/kmwr6HYhK/RI/OkhD84k8ntalo0iJjZikgq1XFvR5M8NPT1x5F7fBwCG3qHfnzeP/Vh/ZxCUA==" 344 | }, 345 | "lodash.get": { 346 | "version": "4.4.2", 347 | "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", 348 | "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=" 349 | }, 350 | "lodash.set": { 351 | "version": "4.3.2", 352 | "resolved": "https://registry.npmjs.org/lodash.set/-/lodash.set-4.3.2.tgz", 353 | "integrity": "sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM=" 354 | }, 355 | "lodash.uniq": { 356 | "version": "4.5.0", 357 | "resolved": "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz", 358 | "integrity": "sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=" 359 | }, 360 | "macos-release": { 361 | "version": "2.3.0", 362 | "resolved": "https://registry.npmjs.org/macos-release/-/macos-release-2.3.0.tgz", 363 | "integrity": "sha512-OHhSbtcviqMPt7yfw5ef5aghS2jzFVKEFyCJndQt2YpSQ9qRVSEv2axSJI1paVThEu+FFGs584h/1YhxjVqajA==" 364 | }, 365 | "minimatch": { 366 | "version": "3.0.4", 367 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", 368 | "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", 369 | "requires": { 370 | "brace-expansion": "^1.1.7" 371 | } 372 | }, 373 | "moment": { 374 | "version": "2.29.4", 375 | "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", 376 | "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==" 377 | }, 378 | "nice-try": { 379 | "version": "1.0.5", 380 | "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", 381 | "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==" 382 | }, 383 | "node-fetch": { 384 | "version": "2.6.7", 385 | "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", 386 | "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", 387 | "requires": { 388 | "whatwg-url": "^5.0.0" 389 | } 390 | }, 391 | "npm-run-path": { 392 | "version": "2.0.2", 393 | "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", 394 | "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", 395 | "requires": { 396 | "path-key": "^2.0.0" 397 | } 398 | }, 399 | "octokit-pagination-methods": { 400 | "version": "1.1.0", 401 | "resolved": "https://registry.npmjs.org/octokit-pagination-methods/-/octokit-pagination-methods-1.1.0.tgz", 402 | "integrity": "sha512-fZ4qZdQ2nxJvtcasX7Ghl+WlWS/d9IgnBIwFZXVNNZUmzpno91SX5bc5vuxiuKoCtK78XxGGNuSCrDC7xYB3OQ==" 403 | }, 404 | "once": { 405 | "version": "1.4.0", 406 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", 407 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", 408 | "requires": { 409 | "wrappy": "1" 410 | } 411 | }, 412 | "os-name": { 413 | "version": "3.1.0", 414 | "resolved": "https://registry.npmjs.org/os-name/-/os-name-3.1.0.tgz", 415 | "integrity": "sha512-h8L+8aNjNcMpo/mAIBPn5PXCM16iyPGjHNWo6U1YO8sJTMHtEtyczI6QJnLoplswm6goopQkqc7OAnjhWcugVg==", 416 | "requires": { 417 | "macos-release": "^2.2.0", 418 | "windows-release": "^3.1.0" 419 | } 420 | }, 421 | "p-finally": { 422 | "version": "1.0.0", 423 | "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", 424 | "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=" 425 | }, 426 | "path-is-absolute": { 427 | "version": "1.0.1", 428 | "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", 429 | "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" 430 | }, 431 | "path-key": { 432 | "version": "2.0.1", 433 | "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", 434 | "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=" 435 | }, 436 | "pump": { 437 | "version": "3.0.0", 438 | "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", 439 | "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", 440 | "requires": { 441 | "end-of-stream": "^1.1.0", 442 | "once": "^1.3.1" 443 | } 444 | }, 445 | "semver": { 446 | "version": "5.7.1", 447 | "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", 448 | "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" 449 | }, 450 | "shebang-command": { 451 | "version": "1.2.0", 452 | "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", 453 | "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", 454 | "requires": { 455 | "shebang-regex": "^1.0.0" 456 | } 457 | }, 458 | "shebang-regex": { 459 | "version": "1.0.0", 460 | "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", 461 | "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=" 462 | }, 463 | "signal-exit": { 464 | "version": "3.0.2", 465 | "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", 466 | "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" 467 | }, 468 | "strip-eof": { 469 | "version": "1.0.0", 470 | "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", 471 | "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=" 472 | }, 473 | "tr46": { 474 | "version": "0.0.3", 475 | "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", 476 | "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" 477 | }, 478 | "tunnel": { 479 | "version": "0.0.6", 480 | "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", 481 | "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==" 482 | }, 483 | "typescript": { 484 | "version": "3.8.3", 485 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.3.tgz", 486 | "integrity": "sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==", 487 | "dev": true 488 | }, 489 | "universal-user-agent": { 490 | "version": "4.0.1", 491 | "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-4.0.1.tgz", 492 | "integrity": "sha512-LnST3ebHwVL2aNe4mejI9IQh2HfZ1RLo8Io2HugSif8ekzD1TlWpHpColOB/eh8JHMLkGH3Akqf040I+4ylNxg==", 493 | "requires": { 494 | "os-name": "^3.1.0" 495 | } 496 | }, 497 | "uuid": { 498 | "version": "8.3.2", 499 | "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", 500 | "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" 501 | }, 502 | "webidl-conversions": { 503 | "version": "3.0.1", 504 | "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", 505 | "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" 506 | }, 507 | "whatwg-url": { 508 | "version": "5.0.0", 509 | "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", 510 | "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", 511 | "requires": { 512 | "tr46": "~0.0.3", 513 | "webidl-conversions": "^3.0.0" 514 | } 515 | }, 516 | "which": { 517 | "version": "1.3.1", 518 | "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", 519 | "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", 520 | "requires": { 521 | "isexe": "^2.0.0" 522 | } 523 | }, 524 | "windows-release": { 525 | "version": "3.2.0", 526 | "resolved": "https://registry.npmjs.org/windows-release/-/windows-release-3.2.0.tgz", 527 | "integrity": "sha512-QTlz2hKLrdqukrsapKsINzqMgOUpQW268eJ0OaOpJN32h272waxR9fkB9VoWRtK7uKHG5EHJcTXQBD8XZVJkFA==", 528 | "requires": { 529 | "execa": "^1.0.0" 530 | } 531 | }, 532 | "wrappy": { 533 | "version": "1.0.2", 534 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 535 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" 536 | } 537 | } 538 | } 539 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "deploy-to-dropbox", 3 | "version": "1.0.0", 4 | "description": "A GitHub Action to deploy to Dropbox", 5 | "main": "dist/index.js", 6 | "scripts": { 7 | "build": "tsc && ncc build dist/main.js", 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git+https://github.com/aTable/deploy-to-dropbox.git" 13 | }, 14 | "author": "", 15 | "license": "MIT", 16 | "bugs": { 17 | "url": "https://github.com/aTable/deploy-to-dropbox/issues" 18 | }, 19 | "homepage": "https://github.com/aTable/deploy-to-dropbox#readme", 20 | "dependencies": { 21 | "@actions/core": "^1.9.1", 22 | "@actions/github": "^2.1.1", 23 | "@types/node": "^13.9.3", 24 | "dropbox": "^4.0.30", 25 | "glob": "^7.1.6" 26 | }, 27 | "devDependencies": { 28 | "@zeit/ncc": "^0.22.0", 29 | "node-fetch": "^2.6.7", 30 | "typescript": "^3.8.3" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /sample/demo.md: -------------------------------------------------------------------------------- 1 | # Demo.md 2 | 3 | This is a demo file to be uploaded 4 | 5 | ## Heading 6 | 7 | ### Sub heading 8 | 9 | ## Heading 10 | -------------------------------------------------------------------------------- /sample/sample2/demo2.md: -------------------------------------------------------------------------------- 1 | # Demo.md 2 | 3 | This is a demo file to be uploaded 4 | 5 | ## Heading 6 | 7 | ### Sub heading 8 | 9 | ## Heading 10 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | const Dropbox = require('dropbox').Dropbox 2 | const fs = require('fs') 3 | const fetch2 = require('node-fetch') 4 | const core = require('@actions/core') 5 | const github = require('@actions/github') 6 | const glob = require('glob') 7 | 8 | const accessToken = core.getInput('DROPBOX_ACCESS_TOKEN') 9 | const globSource = core.getInput('GLOB') 10 | const dropboxPathPrefix = core.getInput('DROPBOX_DESTINATION_PATH_PREFIX') 11 | const isDebug = core.getInput('DEBUG') 12 | const dropbox = new Dropbox({accessToken, fetch: fetch2}) 13 | 14 | function uploadMuhFile(filePath: string): Promise { 15 | const file = fs.readFileSync(filePath) 16 | const destinationPath = `${dropboxPathPrefix}${filePath}` 17 | if (isDebug) console.log('uploaded file to Dropbox at: ', destinationPath) 18 | return dropbox 19 | .filesUpload({path: destinationPath, contents: file}) 20 | .then((response: any) => { 21 | if (isDebug) console.log(response) 22 | return response 23 | }) 24 | .catch((error: any) => { 25 | if (isDebug) console.error(error) 26 | return error 27 | }) 28 | } 29 | 30 | glob(globSource, {}, (err: any, files: string[]) => { 31 | if (err) core.setFailed('Error: glob failed', err) 32 | Promise.all(files.map(uploadMuhFile)) 33 | .then((all) => { 34 | console.log('all files uploaded', all) 35 | }) 36 | .catch((err) => { 37 | console.error('error', err) 38 | }) 39 | }) 40 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": ["dom", "dom.iterable", "esnext"], 5 | "allowJs": true, 6 | "skipLibCheck": true, 7 | "esModuleInterop": true, 8 | "allowSyntheticDefaultImports": true, 9 | "strict": true, 10 | "forceConsistentCasingInFileNames": true, 11 | "module": "esnext", 12 | "moduleResolution": "node", 13 | "resolveJsonModule": true, 14 | "isolatedModules": false, 15 | "noEmit": false, 16 | "jsx": "react", 17 | "outDir": "dist" 18 | }, 19 | "include": ["src/**/*"] 20 | } 21 | --------------------------------------------------------------------------------