├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.yml │ ├── feature_request.yml │ └── question.yml ├── dependabot.yml ├── pull_request_template.md └── workflows │ ├── automerge.yml │ ├── dependency-review.yml │ ├── devskim.yml │ ├── msdo.yml │ ├── osv-scanner.yml │ ├── update-prs.yml │ └── yamllint.yml ├── .gitignore ├── .whitesource ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SECURITY.md ├── birthday-reminders ├── Code.gs └── README.md └── export-to-office ├── Code.gs └── README.md /.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | description: Create a bug report. 4 | title: "[Bug] " 5 | labels: 6 | - bug 7 | assignees: 8 | - thomasleplus 9 | body: 10 | - type: markdown 11 | attributes: 12 | value: | 13 | Thanks for taking the time to fill out this bug report! 14 | - type: checkboxes 15 | attributes: 16 | label: Is there an existing issue for this? 17 | description: Search to see if an issue already exists for the bug you encountered. 18 | options: 19 | - label: I have searched the existing issues 20 | required: true 21 | - type: textarea 22 | attributes: 23 | label: Current Behavior 24 | description: A concise description of what you're experiencing. 25 | validations: 26 | required: true 27 | - type: textarea 28 | attributes: 29 | label: Expected Behavior 30 | description: A concise description of what you expected to happen. 31 | validations: 32 | required: true 33 | - type: textarea 34 | attributes: 35 | label: version 36 | description: | 37 | Version where you observed this issue 38 | placeholder: | 39 | vX.Y.Z 40 | render: markdown 41 | validations: 42 | required: true 43 | - type: textarea 44 | id: logs 45 | attributes: 46 | label: Relevant log output 47 | description: | 48 | Copy and paste any relevant log output. 49 | This will be automatically formatted into code, so no need for backticks. 50 | Enable debug logging, either on GitHub Actions, or when running locally. 51 | render: shell 52 | validations: 53 | required: true 54 | - type: textarea 55 | attributes: 56 | label: Steps To Reproduce 57 | description: | 58 | Steps to reproduce the issue. 59 | placeholder: | 60 | 1. In this environment... 61 | 1. With this config... 62 | 1. Run '...' 63 | 1. See error... 64 | validations: 65 | required: true 66 | - type: textarea 67 | attributes: 68 | label: Anything else? 69 | description: | 70 | Links? References? Anything that will give us more context about the issue you are encountering! 71 | 72 | Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in. 73 | validations: 74 | required: false 75 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | description: Suggest a new feature for this project. 4 | title: "[Feature] " 5 | labels: 6 | - enhancement 7 | assignees: 8 | - thomasleplus 9 | body: 10 | - type: markdown 11 | attributes: 12 | value: | 13 | Thanks for taking the time to fill out this feature request! 14 | - type: textarea 15 | attributes: 16 | label: Feature description 17 | description: | 18 | A clear and concise description of what the desired feature is and why it would be useful. 19 | render: markdown 20 | validations: 21 | required: true 22 | - type: textarea 23 | attributes: 24 | label: Anything else? 25 | description: | 26 | If you think that there are some implementation details to be taken into consideration, or anything that is not obvious from the previous description, please specify it here. 27 | 28 | Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in. 29 | render: markdown 30 | validations: 31 | required: false 32 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Question 3 | description: Ask a question. 4 | title: "[Question] " 5 | labels: 6 | - question 7 | assignees: 8 | - thomasleplus 9 | body: 10 | - type: markdown 11 | attributes: 12 | value: | 13 | Thanks for taking the time to fill out this feature request! 14 | - type: textarea 15 | attributes: 16 | label: What is your question? 17 | description: Please include as many details and examples as possible. 18 | render: markdown 19 | validations: 20 | required: true 21 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: 2 3 | updates: 4 | - package-ecosystem: "github-actions" 5 | directory: "/" 6 | schedule: 7 | interval: "daily" 8 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Readiness checklist 4 | 5 | 6 | Please check the boxes below to confirm that you have followed the 7 | required guidelines for contributions: 8 | 9 | - [ ] If this pull request includes code changes, they were all properly tested. Automated tests were also included where possible. 10 | - [ ] If applicagle, this pull request includes the relevant documentation for this change. 11 | - [ ] If this pull request is related to an existing issue, you can use the same description below but in any case include a [link](https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue) like `Fixes #ISSUE_NUMBER.` or `Closese #ISSUE_NUMBER.`. 12 | - [ ] All the commits in this pull request were squashed into a single commit. That commit is [signed](https://docs.github.com/en/authentication/managing-commit-signature-verification). 13 | 14 | 15 | 16 | ## Description 17 | 18 | -------------------------------------------------------------------------------- /.github/workflows/automerge.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: "Dependabot auto-merge" 3 | on: pull_request 4 | 5 | permissions: 6 | actions: write 7 | contents: write 8 | pull-requests: write 9 | 10 | jobs: 11 | dependabot: 12 | runs-on: ubuntu-latest 13 | if: ${{ github.actor == 'dependabot[bot]' }} 14 | steps: 15 | - name: Authenticate CLI with a PAT 16 | env: 17 | RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }} 18 | if: env.RELEASE_TOKEN != '' 19 | shell: bash 20 | run: echo "${RELEASE_TOKEN}" | gh auth login --with-token 21 | - name: Enable auto-merge for Dependabot PRs 22 | shell: bash 23 | run: | 24 | # Checking the PR title is a poor substitute for the actual PR changes 25 | # but as long as this is used only with dependabot PRs, 26 | # it should be safe to assume that the title is not misleading. 27 | regexp='^Bump .* from [0-9]+\.[0-9]+(\.[0-9]+)?(\.[0-9]+)?(\-[a-z]+)? to [0-9]+\.[0-9]+(\.[0-9]+)?(\.[0-9]+)?(\-[a-z]+)?( in .*)?$' 28 | if ! [[ "${PR_TITLE}" =~ ${regexp} ]] ; then 29 | echo 'Non-semver upgrade, needs manual review.' 30 | elif [ "${BASH_REMATCH[3]}" != "${BASH_REMATCH[6]}" ] ; then 31 | echo 'Version suffixes do not match, needs manual review.' 32 | else 33 | echo 'Automated review approval.' 34 | gh pr review --approve "${PR_URL}" 35 | fi 36 | gh pr merge --auto --squash "${PR_URL}" 37 | env: 38 | PR_TITLE: ${{github.event.pull_request.title}} 39 | PR_URL: ${{github.event.pull_request.html_url}} 40 | GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} 41 | -------------------------------------------------------------------------------- /.github/workflows/dependency-review.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: "Dependency Review" 3 | on: [pull_request] 4 | 5 | permissions: 6 | contents: read 7 | 8 | jobs: 9 | dependency-review: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: "Checkout Repository" 13 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 14 | - name: "Dependency Review" 15 | uses: actions/dependency-review-action@da24556b548a50705dd671f47852072ea4c105d9 # v4.7.1 16 | -------------------------------------------------------------------------------- /.github/workflows/devskim.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This workflow uses actions that are not certified by GitHub. 3 | # They are provided by a third-party and are governed by 4 | # separate terms of service, privacy policy, and support 5 | # documentation. 6 | 7 | name: DevSkim 8 | 9 | on: 10 | push: 11 | branches: ["main"] 12 | pull_request: 13 | branches: ["main"] 14 | schedule: 15 | - cron: "0 0 * * 0" 16 | 17 | permissions: {} 18 | 19 | jobs: 20 | lint: 21 | name: DevSkim 22 | runs-on: ubuntu-latest 23 | permissions: 24 | actions: read 25 | contents: read 26 | security-events: write 27 | steps: 28 | - name: Checkout code 29 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 30 | 31 | - name: Run DevSkim scanner 32 | uses: microsoft/DevSkim-Action@4b5047945a44163b94642a1cecc0d93a3f428cc6 # v1.0.16 33 | 34 | - name: Upload DevSkim scan results to GitHub Security tab 35 | uses: github/codeql-action/upload-sarif@fca7ace96b7d713c7035871441bd52efbe39e27e # v3.28.19 36 | with: 37 | should-scan-archives: true 38 | sarif_file: devskim-results.sarif 39 | -------------------------------------------------------------------------------- /.github/workflows/msdo.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This workflow uses actions that are not certified by GitHub. 3 | # They are provided by a third-party and are governed by 4 | # separate terms of service, privacy policy, and support 5 | # documentation. 6 | 7 | name: MSDO 8 | 9 | on: 10 | push: 11 | branches: ["main"] 12 | pull_request: 13 | branches: ["main"] 14 | schedule: 15 | - cron: "0 0 * * 0" 16 | 17 | permissions: {} 18 | 19 | jobs: 20 | lint: 21 | name: MSDO 22 | runs-on: windows-latest 23 | permissions: 24 | security-events: write 25 | steps: 26 | - name: Checkout code 27 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 28 | 29 | - name: Run Microsoft Security DevOps scanner 30 | uses: microsoft/security-devops-action@08976cb623803b1b36d7112d4ff9f59eae704de0 # v1.12.0 31 | id: msdo 32 | 33 | - name: Upload MSDO scan results to GitHub Security tab 34 | uses: github/codeql-action/upload-sarif@fca7ace96b7d713c7035871441bd52efbe39e27e # v3.28.19 35 | with: 36 | sarif_file: ${{ steps.msdo.outputs.sarifFile }} 37 | -------------------------------------------------------------------------------- /.github/workflows/osv-scanner.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This workflow uses actions that are not certified by GitHub. 3 | # They are provided by a third-party and are governed by 4 | # separate terms of service, privacy policy, and support 5 | # documentation. 6 | 7 | # A sample workflow which sets up periodic OSV-Scanner scanning for vulnerabilities, 8 | # in addition to a PR check which fails if new vulnerabilities are introduced. 9 | # 10 | # For more examples and options, including how to ignore specific vulnerabilities, 11 | # see https://google.github.io/osv-scanner/github-action/ 12 | 13 | name: OSV-Scanner 14 | 15 | on: 16 | pull_request: 17 | branches: ["main"] 18 | push: 19 | branches: ["main"] 20 | schedule: 21 | - cron: "0 0 * * 0" 22 | workflow_dispatch: 23 | 24 | permissions: 25 | # Require writing security events to upload SARIF file to security tab 26 | security-events: write 27 | # Read commit contents 28 | contents: read 29 | # Actions read-only 30 | actions: read 31 | 32 | jobs: 33 | scan: 34 | uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml@e69cc6c86b31f1e7e23935bbe7031b50e51082de" # v2.0.2 35 | with: 36 | # Example of specifying custom arguments 37 | scan-args: |- 38 | -r 39 | --skip-git 40 | ./ 41 | -------------------------------------------------------------------------------- /.github/workflows/update-prs.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Update PRs 3 | 4 | on: 5 | push: 6 | schedule: 7 | - cron: "0 0 * * *" 8 | workflow_dispatch: 9 | 10 | permissions: 11 | pull-requests: write 12 | contents: write 13 | 14 | jobs: 15 | update: 16 | if: startsWith(github.ref, 'refs/heads/') 17 | runs-on: ubuntu-latest 18 | steps: 19 | - name: Update Pull Requests 20 | uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 21 | with: 22 | script: | 23 | const opts = github.rest.pulls.list.endpoint.merge({ 24 | owner: context.repo.owner, 25 | repo: context.repo.repo, 26 | state: 'open', 27 | base: context.ref.replace('refs/heads/', ''), 28 | }) 29 | const prs = await github.paginate(opts) 30 | for (const pr of prs) { 31 | core.debug(JSON.stringify(pr)) 32 | core.info(`Updating PR #${pr.number}`) 33 | github.rest.pulls.updateBranch({ 34 | owner: context.repo.owner, 35 | repo: context.repo.repo, 36 | pull_number: pr.number, 37 | }).then(function(result) { 38 | core.debug(JSON.stringify(result)) 39 | core.info(JSON.stringify(result.data)) 40 | }).catch(function(error) { 41 | core.error(error) 42 | }) 43 | } 44 | -------------------------------------------------------------------------------- /.github/workflows/yamllint.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: "YAMLLint" 3 | 4 | on: 5 | push: 6 | pull_request: 7 | schedule: 8 | - cron: "0 0 * * 0" 9 | workflow_dispatch: 10 | 11 | permissions: {} 12 | 13 | jobs: 14 | lint: 15 | name: Check with YAMLLint 16 | runs-on: ubuntu-latest 17 | steps: 18 | - name: Check out 19 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 20 | - name: Install YAMLLint 21 | shell: bash 22 | run: | 23 | pip install yamllint==1.37.1 24 | msg="$(pip list --outdated | grep -e yamllint || true)" 25 | if [ -n "${msg}" ]; then 26 | >&2 echo "ERROR: outdated: ${msg}" 27 | exit 1 28 | fi 29 | - name: Run YAMLLint 30 | shell: bash 31 | run: "yamllint -d '{extends: default, rules: {line-length: disable}}' ." 32 | -------------------------------------------------------------------------------- /.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 | dist 84 | 85 | # Gatsby files 86 | .cache/ 87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 88 | # https://nextjs.org/blog/next-9-1#public-directory-support 89 | # public 90 | 91 | # vuepress build output 92 | .vuepress/dist 93 | 94 | # Serverless directories 95 | .serverless/ 96 | 97 | # FuseBox cache 98 | .fusebox/ 99 | 100 | # DynamoDB Local files 101 | .dynamodb/ 102 | 103 | # TernJS port file 104 | .tern-port 105 | -------------------------------------------------------------------------------- /.whitesource: -------------------------------------------------------------------------------- 1 | { 2 | "scanSettings": { 3 | "baseBranches": [] 4 | }, 5 | "checkRunSettings": { 6 | "vulnerableCheckRunConclusionLevel": "failure", 7 | "displayMode": "diff" 8 | }, 9 | "issueSettings": { 10 | "minSeverityLevel": "LOW", 11 | "issueType": "DEPENDENCY" 12 | } 13 | } -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, caste, color, religion, or sexual 10 | identity and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | - Demonstrating empathy and kindness toward other people 21 | - Being respectful of differing opinions, viewpoints, and experiences 22 | - Giving and gracefully accepting constructive feedback 23 | - Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | - Focusing on what is best not just for us as individuals, but for the overall 26 | community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | - The use of sexualized language or imagery, and sexual attention or advances of 31 | any kind 32 | - Trolling, insulting or derogatory comments, and personal or political attacks 33 | - Public or private harassment 34 | - Publishing others' private information, such as a physical or email address, 35 | without their explicit permission 36 | - Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official email address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | [INSERT CONTACT METHOD]. 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series of 86 | actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or permanent 93 | ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within the 113 | community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.1, available at 119 | [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. 120 | 121 | Community Impact Guidelines were inspired by 122 | [Mozilla's code of conduct enforcement ladder][Mozilla CoC]. 123 | 124 | For answers to common questions about this code of conduct, see the FAQ at 125 | [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at 126 | [https://www.contributor-covenant.org/translations][translations]. 127 | 128 | [homepage]: https://www.contributor-covenant.org 129 | [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html 130 | [Mozilla CoC]: https://github.com/mozilla/diversity 131 | [FAQ]: https://www.contributor-covenant.org/faq 132 | [translations]: https://www.contributor-covenant.org/translations 133 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | ## Creating an issue 4 | 5 | If you have found a bug, want to request an enhancement or simply ask 6 | a question, feel free to open an 7 | [issue](https://github.com/thomasleplus/google-apps-scripts/issues/new/choose). 8 | 9 | For security-related issues, please see our [security policy](/SECURITY.md). 10 | 11 | ## Submitting a pull request 12 | 13 | If you want to contribute code, documentation etc. you can open a pull 14 | request. We then kindly ask that: 15 | 16 | - before working or submitting a large pull request, please open an 17 | issue to discuss what you have in mind and check that there is not 18 | an existing solution or a different approach. 19 | - all code changes must be tested manually and automated tests should 20 | be included when possible. 21 | - all necessary documentation should be included as well. 22 | - commits on a single pull request must be squashed together to keep 23 | make reviews easier. 24 | - commits must be signed (this is supported by most Git clients as 25 | well as the GitHub web UI, see link below). 26 | 27 | ## Resources 28 | 29 | - [Managing commit signature verification](https://docs.github.com/en/authentication/managing-commit-signature-verification) 30 | - [Using Pull Requests](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests) 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | https://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2022 Thomas Leplus 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | https://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Google Apps Scripts 2 | 3 | A collection of useful Google Apps Scripts. 4 | 5 | ## [Birthday Reminders](birthday-reminders/) 6 | 7 | Receive an email notification for each birthday in your 'Birthdays' calendar. 8 | 9 | ## [Export To Office](export-to-office/) 10 | 11 | Export all Google Docs, Google Spreasheets and Google Slides to Microsoft Word, Microsoft Excel and Microsoft Powerpoint format (respectively). 12 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | Currently all versions of this project are 6 | being supported with security updates. 7 | 8 | | Version | Supported | 9 | | --------------- | ------------------ | 10 | | 1.x.x and above | :white_check_mark: | 11 | 12 | ## Reporting a Vulnerability 13 | 14 | For responsible disclosure, please use [this link](https://github.com/thomasleplus/google-apps-scripts/security/advisories/new) (GitHub account required) to report an issue privatly. Otherwise you can also contact me using the info on my [profile page](https://github.com/thomasleplus). 15 | -------------------------------------------------------------------------------- /birthday-reminders/Code.gs: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | function sendBirthdayRemindersByEmail() { 4 | const properties = PropertiesService.getScriptProperties(); 5 | 6 | let calendarName = properties.getProperty("calendar"); 7 | if (calendarName == null) { 8 | calendarName = "Birthdays"; 9 | } 10 | console.log("calendarName=" + calendarName); 11 | 12 | let offset = properties.getProperty("offset"); 13 | if (offset == null) { 14 | offset = 0; 15 | } 16 | console.log("offset=" + offset); 17 | 18 | const eventDate = new Date( 19 | new Date().getTime() + offset * 24 * 60 * 60 * 1000, 20 | ); 21 | console.log("eventDate=" + eventDate); 22 | 23 | const email = Session.getActiveUser().getEmail(); 24 | console.log("email=" + email); 25 | 26 | let subjectTemplate = properties.getProperty("emailSubjectTemplate"); 27 | if (subjectTemplate == null) { 28 | subjectTemplate = "${event.getTitle()}"; 29 | } 30 | console.log("subjectTemplate=" + subjectTemplate); 31 | 32 | let bodyTemplate = properties.getProperty("emailBodyTemplate"); 33 | if (bodyTemplate == null) { 34 | bodyTemplate = "${event.getDescription()}"; 35 | } 36 | console.log("bodyTemplate=" + bodyTemplate); 37 | 38 | CalendarApp.getCalendarsByName(calendarName).forEach(function (calendar) { 39 | console.log('Found calendar "' + calendar.getName() + '"'); 40 | calendar.getEventsForDay(eventDate).forEach(function (event) { 41 | console.log('Found event "' + event.getTitle() + '"'); 42 | const subject = processTemplate(subjectTemplate, event, properties); 43 | const body = processTemplate(bodyTemplate, event, properties); 44 | console.log( 45 | 'Emailing "' + subject + '" to ' + email + ' with body "' + body + '"', 46 | ); 47 | MailApp.sendEmail({ 48 | to: email, 49 | subject: subject, 50 | htmlBody: body, 51 | }); 52 | }); 53 | }); 54 | } 55 | 56 | function processTemplate(template, event, properties) { 57 | return template.replace( 58 | /\$\{(event|properties)\.([^\}]+)\}/g, 59 | function (match, p1, p2, offset, string, groups) { 60 | if (p1 == "event") { 61 | console.log("Template matches ${event." + p2 + "}"); 62 | if (p2.endsWith("()")) { 63 | console.log("Invoking event." + p2); 64 | return event[p2.slice(0, -2)]() || match; 65 | } 66 | return match; 67 | } else if (p1 == "properties") { 68 | console.log("Template matches ${properties." + p2 + "}"); 69 | return properties.getProperty(p2) || match; 70 | } 71 | return string; 72 | }, 73 | ); 74 | } 75 | -------------------------------------------------------------------------------- /birthday-reminders/README.md: -------------------------------------------------------------------------------- 1 | # Birthday Reminders 2 | 3 | Receive an email notification for each birthday in your 'Birthdays' calendar. This script requires you to use Gmail and Google Calendar. If you are also using Google Contacts, you can [create a birthdays' calendar automatically](https://support.google.com/calendar/answer/6084659) from your contacts. 4 | 5 | I run this daily using a [standalone script](https://developers.google.com/apps-script/guides/standalone) with [time-driven trigger](https://developers.google.com/apps-script/guides/triggers/installable#time-driven_triggers). 6 | 7 | The script has two optional [script properties](https://developers.google.com/apps-script/guides/properties#manage_script_properties_manually): 8 | 9 | - calendar: the name of the Google Calendar to monitor (default is 'Birthdays'). 10 | - offset: the numbers of days before an event that you want to receive the email (default is 0). 11 | - subjectTemplate: template used to generate the email subject, see syntax below (default is ${event.getTitle()}). 12 | - bodyTemplate: template used to generate the email body, see syntax below (default is ${event.getDescription()}). 13 | 14 | The syntax for the template properties is a string where the following substitutions will be conducted: 15 | 16 | - all occurrences of the ${event.getFoo()} where getFoo() is a method with no argument from the [Calendar event object](https://developers.google.com/apps-script/reference/calendar/calendar-event) will be replaced with the corresponding value returned by the method. 17 | - all occurrences of the ${properties.foo} where foo can be any [script property](https://developers.google.com/apps-script/guides/properties#manage_script_properties_manually) will be replaced with the corresponding value. 18 | -------------------------------------------------------------------------------- /export-to-office/Code.gs: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | function exportToOffice() { 4 | let expiry = PropertiesService.getScriptProperties().getProperty("expiry"); 5 | if (expiry == null) { 6 | expiry = 30; 7 | } 8 | let folderName = 9 | PropertiesService.getScriptProperties().getProperty("folder"); 10 | if (folderName == null) { 11 | folderName = "Export"; 12 | } 13 | const modulo = new Date().getUTCHours(); 14 | const now = new Date(); 15 | const description = "#ExportedToOffice"; 16 | const conversions = [ 17 | [ 18 | "application/vnd.google-apps.spreadsheet", 19 | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", 20 | ".xslx", 21 | ], 22 | [ 23 | "application/vnd.google-apps.document", 24 | "application/vnd.openxmlformats-officedocument.wordprocessingml.document", 25 | ".docx", 26 | ], 27 | [ 28 | "application/vnd.google-apps.presentation", 29 | "application/vnd.openxmlformats-officedocument.presentationml.presentation", 30 | ".pptx", 31 | ], 32 | ]; 33 | const folders = DriveApp.getRootFolder().getFoldersByName(folderName); 34 | if (!folders.hasNext()) { 35 | throw 'Folder "' + folderName + '" not found'; 36 | } 37 | const folder = folders.next(); 38 | if (folders.hasNext()) { 39 | throw 'More than one "' + folderName + '" folder'; 40 | } 41 | const oldFiles = folder.getFiles(); 42 | while (oldFiles.hasNext()) { 43 | const oldFile = oldFiles.next(); 44 | if (oldFile.getDescription() === description) { 45 | if (oldFile.getDateCreated() - now > expiry) { 46 | console.log('Deleting obsolete file "' + oldFile.getName() + '"'); 47 | oldFile.setTrashed(true); 48 | } else if (oldFile.getName().charCodeAt(0) % 24 === modulo) { 49 | console.log('Deleting file "' + oldFile.getName() + '"'); 50 | oldFile.setTrashed(true); 51 | } 52 | } 53 | } 54 | for (var i = 0; i < conversions.length; i++) { 55 | const conversion = conversions[i]; 56 | console.log('Searching for "' + conversion[0] + '" files...'); 57 | const files = DriveApp.getFilesByType(conversion[0]); 58 | while (files.hasNext()) { 59 | const file = files.next(); 60 | if (file.isTrashed()) { 61 | console.log('Skipping trashed file "' + file.getName() + '"'); 62 | continue; 63 | } 64 | if ( 65 | file.getAccess(Session.getActiveUser()) !== DriveApp.Permission.OWNER 66 | ) { 67 | console.log('Skipping shared file "' + file.getName() + '"'); 68 | continue; 69 | } 70 | if (file.getName().charCodeAt(0) % 24 === modulo) { 71 | console.log('Converting "' + file.getName() + '"'); 72 | const blob = getFileAsBlob(file.getId(), conversion[1]); 73 | const newFile = folder.createFile(blob); 74 | newFile.setName(file.getName() + conversion[2]); 75 | newFile.setDescription(description); 76 | } 77 | } 78 | } 79 | } 80 | 81 | function getFileAsBlob(fileId, mimeType) { 82 | const response = UrlFetchApp.fetch( 83 | "https://www.googleapis.com/drive/v3/files/" + 84 | fileId + 85 | "/export?mimeType=" + 86 | encodeURIComponent(mimeType), 87 | { 88 | headers: { 89 | Authorization: "Bearer " + ScriptApp.getOAuthToken(), 90 | }, 91 | }, 92 | ); 93 | return response.getBlob(); 94 | } 95 | -------------------------------------------------------------------------------- /export-to-office/README.md: -------------------------------------------------------------------------------- 1 | # Export To Office 2 | 3 | Export all Google Docs, Google Spreasheets and Google Slides to Microsoft Word, Microsoft Excel and Microsoft Powerpoint format (respectively). 4 | 5 | Since Apps Scripts have a 6-minute runtime limite, I run this script hourly using a [standalone script](https://developers.google.com/apps-script/guides/standalone) with [time-driven trigger](https://developers.google.com/apps-script/guides/triggers/installable#time-driven_triggers). Each run exports 1/24th of the files in Google Drive so at the end of each day, all files should have been exported. 6 | 7 | The script has two optional [script properties](https://developers.google.com/apps-script/guides/properties#manage_script_properties_manually): 8 | 9 | - folder: the name of the Google Drive folder to save the converted files (default is 'Export'). This folder must be at the root of your Google Drive (to avoid name collisions). 10 | - expiry: the number of days after which an orphan exported file gets deleted (default is 30). 11 | --------------------------------------------------------------------------------