├── .husky
├── .gitignore
└── pre-commit
├── .gitignore
├── .gitattributes
├── .github
├── ISSUE_TEMPLATE
│ ├── config.yml
│ ├── blank-issue.md
│ ├── question.md
│ └── bug_report.md
├── workflows
│ ├── stale.yml
│ ├── versioning.yml
│ ├── label-sync.yml
│ ├── codesee-arch-diagram.yml
│ ├── test.yml
│ ├── export-labels.yml
│ └── codeql-analysis.yml
├── FUNDING.yml
├── dependabot.yml
└── labels.yml
├── .prettierrc
├── CONTRIBUTING.md
├── .eslintrc.js
├── .devcontainer
└── devcontainer.json
├── LICENSE
├── package.json
├── action.yml
├── src
├── util.ts
├── io.ts
└── main.ts
├── tsconfig.json
├── CODE_OF_CONDUCT.md
├── .all-contributorsrc
└── README.md
/.husky/.gitignore:
--------------------------------------------------------------------------------
1 | _
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | build
3 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto eol=lf
2 | lib/* linguist-generated
3 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/config.yml:
--------------------------------------------------------------------------------
1 | blank_issues_enabled: false
2 |
--------------------------------------------------------------------------------
/.husky/pre-commit:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | . "$(dirname "$0")/_/husky.sh"
3 |
4 | npm run build
5 | git add lib
6 |
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "semi": false,
3 | "singleQuote": true,
4 | "tabWidth": 2,
5 | "useTabs": false,
6 | "trailingComma": "none"
7 | }
8 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/blank-issue.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Blank issue
3 | about: Just a blank template
4 | title: ''
5 | labels: 'status: pending'
6 | assignees: ''
7 |
8 | ---
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/question.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Question
3 | about: Ask a question on how to use the action
4 | title: ''
5 | labels: 'type: question'
6 | assignees: ''
7 |
8 | ---
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.github/workflows/stale.yml:
--------------------------------------------------------------------------------
1 | name: 'Handle stale issues and PR'
2 | on:
3 | schedule:
4 | - cron: '00 5,17 * * *'
5 | workflow_dispatch:
6 |
7 | jobs:
8 | stale:
9 | uses: EndBug/workflows/.github/workflows/stale.yml@main
10 |
--------------------------------------------------------------------------------
/.github/workflows/versioning.yml:
--------------------------------------------------------------------------------
1 | name: Update tags
2 |
3 | on:
4 | release:
5 | types: [published, edited]
6 |
7 | jobs:
8 | actions-tagger:
9 | runs-on: windows-2022
10 | steps:
11 | - uses: Actions-R-Us/actions-tagger@v2
12 | with:
13 | publish_latest_tag: true
14 |
--------------------------------------------------------------------------------
/.github/workflows/label-sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync labels
2 | on:
3 | push:
4 | branches:
5 | - main
6 | paths:
7 | - '.github/labels.yml'
8 | workflow_dispatch:
9 |
10 | jobs:
11 | sync:
12 | name: Run EndBug/label-sync
13 | runs-on: ubuntu-latest
14 | steps:
15 | - uses: actions/checkout@v4
16 | - uses: EndBug/label-sync@v2
17 | with:
18 | config-file: '.github/labels.yml'
19 |
--------------------------------------------------------------------------------
/.github/workflows/codesee-arch-diagram.yml:
--------------------------------------------------------------------------------
1 | # This workflow was added by CodeSee. Learn more at https://codesee.io/
2 | # This is v2.0 of this workflow file
3 | on:
4 | push:
5 | branches:
6 | - main
7 | pull_request_target:
8 | types: [opened, synchronize, reopened]
9 |
10 | name: CodeSee
11 |
12 | permissions: read-all
13 |
14 | jobs:
15 | codesee:
16 | runs-on: ubuntu-latest
17 | continue-on-error: true
18 | name: Analyze the repo with CodeSee
19 | steps:
20 | - uses: Codesee-io/codesee-action@v2
21 | with:
22 | codesee-token: ${{ secrets.CODESEE_ARCH_DIAG_API_TOKEN }}
23 |
--------------------------------------------------------------------------------
/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | name: Test
2 | on:
3 | push:
4 | pull_request:
5 | workflow_dispatch:
6 |
7 | jobs:
8 | build:
9 | name: Build
10 | runs-on: ubuntu-20.04
11 | steps:
12 | - uses: actions/checkout@v4
13 | - uses: actions/setup-node@v3
14 | with:
15 | cache: npm
16 | - run: npm ci
17 | - run: npm run build
18 |
19 | lint:
20 | name: Lint
21 | runs-on: ubuntu-20.04
22 | steps:
23 | - uses: actions/checkout@v4
24 | - uses: actions/setup-node@v3
25 | with:
26 | cache: npm
27 | - run: npm ci
28 | - run: npm run lint
29 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: [endbug] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4 | patreon: # Replace with a single Patreon username
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | otechie: # Replace with a single Otechie username
12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
13 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | If you want to contribute to this project, check out this steps!
4 |
5 | 1. Check out existing features to make sure your case is not already covered. Also, try [searching open or closed issues](https://github.com/EndBug/add-and-commit/issues) that may cover the same topic.
6 | 2. Either [open a new issue](https://github.com/EndBug/add-and-commit/issues/new/choose) or comment on an existing one to let everyone know what you're working on.
7 | 3. Edit the source files to implement your feature or fix.
8 | 4. Build the action and test it in a test repo.
9 | 5. Update the [action manifest](./action.yml) AND the [README](./README.md) with your changes.
10 | 6. [Open a PR](https://github.com/EndBug/add-and-commit/compare).
11 |
12 | Thanks! 💖
13 |
14 |
--------------------------------------------------------------------------------
/.github/workflows/export-labels.yml:
--------------------------------------------------------------------------------
1 | name: Export label config
2 | on:
3 | # You can run this with every event, but it's better to run it only when you actually need it.
4 | workflow_dispatch:
5 |
6 | jobs:
7 | labels:
8 | runs-on: ubuntu-latest
9 |
10 | steps:
11 | - uses: EndBug/export-label-config@main
12 | with:
13 | # This is needed if you're dealing with private repos.
14 | token: ${{ secrets.GITHUB_TOKEN }}
15 |
16 | # Set this to `true` if you want to get the raw API reponse. Defaults to `false`.
17 | raw-result: false
18 |
19 | # By default every label entry will have an `aliases` property set to an empty array.
20 | # It's for EndBug/label-sync, if you don't want it you cans set this to `false`
21 | add-aliases: true
22 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | commonjs: true,
4 | es6: true,
5 | node: true
6 | },
7 | extends: ['eslint:recommended', 'plugin:prettier/recommended'],
8 | globals: {},
9 | parser: '@typescript-eslint/parser',
10 | parserOptions: {
11 | ecmaVersion: 6,
12 | sourceType: 'module'
13 | },
14 | plugins: ['@typescript-eslint'],
15 | ignorePatterns: ['lib/*'],
16 | rules: {
17 | 'prettier/prettier': 'warn',
18 | 'no-cond-assign': [2, 'except-parens'],
19 | 'no-unused-vars': 0,
20 | 'no-redeclare': 0,
21 | '@typescript-eslint/no-unused-vars': 1,
22 | 'no-empty': [
23 | 'error',
24 | {
25 | allowEmptyCatch: true
26 | }
27 | ],
28 | 'prefer-const': [
29 | 'warn',
30 | {
31 | destructuring: 'all'
32 | }
33 | ],
34 | 'spaced-comment': 'warn'
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | # To get started with Dependabot version updates, you'll need to specify which
2 | # package ecosystems to update and where the package manifests are located.
3 | # Please see the documentation for all configuration options:
4 | # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5 |
6 | version: 2
7 | updates:
8 | - package-ecosystem: 'npm' # See documentation for possible values
9 | directory: '/' # Location of package manifests
10 | schedule:
11 | interval: 'weekly'
12 | commit-message:
13 | prefix: 'chore'
14 | include: 'scope'
15 | labels:
16 | - 'type: chore'
17 | - package-ecosystem: github-actions
18 | directory: /
19 | schedule:
20 | interval: weekly
21 | open-pull-requests-limit: 10
22 | commit-message:
23 | include: scope
24 | prefix: ci
25 | labels:
26 | - 'type: chore'
27 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Report an issue with the action
4 | title: ''
5 | labels: 'status: pending'
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is. If a particular error is shown
12 |
13 | **Workflow used**
14 | Provide a snippet of the workflow and/or a link to it (use the commit sha as the ref when you link it, so that it's not influenced by other changes). If you only share a section of the workflow, make sure it includes the step that uses the action!
15 |
16 | **Expected behavior**
17 | A clear and concise description of what you expected to happen.
18 |
19 | **Logs**
20 | Either provide a link to the action run or (if your repo is private) paste here the logs from the step that uses it. If you paste the logs, please use this template, and remember to paste the logs from all the different sections.
21 |
22 | Logs
23 |
Your logs here.
24 |
25 |
--------------------------------------------------------------------------------
/.devcontainer/devcontainer.json:
--------------------------------------------------------------------------------
1 | // For format details, see https://aka.ms/devcontainer.json. For config options, see the
2 | // README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
3 | {
4 | "name": "Ubuntu",
5 | // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6 | "image": "mcr.microsoft.com/devcontainers/base:jammy",
7 | "features": {
8 | "ghcr.io/devcontainers/features/github-cli:1": {},
9 | "ghcr.io/devcontainers/features/node:1": {}
10 | }
11 | // Features to add to the dev container. More info: https://containers.dev/features.
12 | // "features": {},
13 | // Use 'forwardPorts' to make a list of ports inside the container available locally.
14 | // "forwardPorts": [],
15 | // Use 'postCreateCommand' to run commands after the container is created.
16 | // "postCreateCommand": "uname -a",
17 | // Configure tool-specific properties.
18 | // "customizations": {},
19 | // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
20 | // "remoteUser": "root"
21 | }
22 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Federico Grandi
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 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "add-and-commit",
3 | "version": "9.1.3",
4 | "private": true,
5 | "description": "Add & commit files from a path directly from GitHub Actions",
6 | "main": "lib/index.js",
7 | "scripts": {
8 | "build": "ncc build src/main.ts --minify --out lib",
9 | "watch": "ncc build src/main.ts --watch --out lib",
10 | "lint": "eslint --ext .ts src",
11 | "lint:fix": "eslint --ext .ts --fix src",
12 | "prepare": "husky install",
13 | "test": "echo \"Error: no test specified\" && exit 1"
14 | },
15 | "repository": {
16 | "type": "git",
17 | "url": "git+https://github.com/EndBug/add-and-commit.git"
18 | },
19 | "keywords": [
20 | "github",
21 | "action",
22 | "version",
23 | "npm",
24 | "node"
25 | ],
26 | "author": "Federico Grandi ",
27 | "license": "MIT",
28 | "bugs": {
29 | "url": "https://github.com/EndBug/add-and-commit/issues"
30 | },
31 | "homepage": "https://github.com/EndBug/add-and-commit#readme",
32 | "dependencies": {
33 | "@actions/core": "^1.10.1",
34 | "actions-toolkit": "github:EndBug/actions-toolkit#core-actions",
35 | "js-yaml": "^4.1.0",
36 | "simple-git": "^3.18.0",
37 | "string-argv": "^0.3.2"
38 | },
39 | "devDependencies": {
40 | "@types/js-yaml": "^4.0.6",
41 | "@types/node": "^12.12.54",
42 | "@typescript-eslint/eslint-plugin": "^6.7.0",
43 | "@typescript-eslint/parser": "^6.7.2",
44 | "@vercel/ncc": "^0.38.0",
45 | "all-contributors-cli": "^6.26.1",
46 | "eslint": "^8.48.0",
47 | "eslint-config-prettier": "^9.0.0",
48 | "eslint-plugin-prettier": "^5.0.0",
49 | "husky": "^8.0.3",
50 | "prettier": "^3.0.3",
51 | "typescript": "^5.2.2"
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/.github/labels.yml:
--------------------------------------------------------------------------------
1 | - name: 'good first issue'
2 | color: '5319e7'
3 | description: 'Good for newcomers'
4 | aliases: []
5 |
6 | - name: 'help wanted'
7 | color: '008672'
8 | description: 'Extra attention is needed'
9 | aliases: []
10 |
11 | - name: 'status: pending'
12 | color: c5def5
13 | description: 'More info is needed before deciding what to do'
14 | aliases: []
15 |
16 | - name: 'status: pinned'
17 | color: 0052cc
18 | description: 'Should not be labeled as stale'
19 | aliases: []
20 |
21 | - name: 'status: stale'
22 | color: fbca04
23 | description: 'Inactive issues and PRs'
24 | aliases: ['stale']
25 |
26 | - name: 'status: wontfix'
27 | color: cfd3d7
28 | description: 'This will not be worked on'
29 | aliases: ['wontfix']
30 |
31 | - name: 'type: bug'
32 | color: d73a4a
33 | description: 'Verified problems that need to be worked on'
34 | aliases: ['bug']
35 |
36 | - name: 'type: chore'
37 | color: C5DEF5
38 | description: 'Code changes that neither fix bugs nor add features (refactoring, dependency chnages, ...)'
39 | aliases: ['dependencies', 'type: dependencies', 'automation', 'type: automation']
40 |
41 | - name: 'type: docs'
42 | color: C5DEF5
43 | description: "Documentation changes"
44 | aliases: ['documentation', 'maintenance', 'type: maintenance']
45 |
46 | - name: 'type: duplicate'
47 | color: cfd3d7
48 | description: 'This issue or pull request already exists'
49 | aliases: ['duplicate']
50 |
51 | - name: 'type: feature'
52 | color: 0E8A16
53 | description: 'New feature or feature request'
54 | aliases: ['enhancement', 'type: enhancement']
55 |
56 | - name: 'type: fix'
57 | color: 1D76DB
58 | description: 'Updates to existing functionalities'
59 | aliases: ['fix']
60 |
61 | - name: 'type: invalid'
62 | color: e4e669
63 | description: "This doesn't seem right"
64 | aliases: ['invalid']
65 |
66 | - name: 'type: not a bug'
67 | color: 0e8a16
68 | description: 'Reports that happen not be our fault'
69 | aliases: ['not a bug']
70 |
71 | - name: 'type: question'
72 | color: d876e3
73 | description: 'Further information is requested'
74 | aliases: ['question']
75 |
--------------------------------------------------------------------------------
/.github/workflows/codeql-analysis.yml:
--------------------------------------------------------------------------------
1 | # For most projects, this workflow file will not need changing; you simply need
2 | # to commit it to your repository.
3 | #
4 | # You may wish to alter this file to override the set of languages analyzed,
5 | # or to provide custom queries or build logic.
6 | #
7 | # ******** NOTE ********
8 | # We have attempted to detect the languages in your repository. Please check
9 | # the `language` matrix defined below to confirm you have the correct set of
10 | # supported CodeQL languages.
11 | #
12 | name: "CodeQL"
13 |
14 | on:
15 | push:
16 | branches: [ main ]
17 | pull_request:
18 | # The branches below must be a subset of the branches above
19 | branches: [ main ]
20 | schedule:
21 | - cron: '40 12 * * 2'
22 |
23 | jobs:
24 | analyze:
25 | name: Analyze
26 | runs-on: ubuntu-latest
27 | permissions:
28 | actions: read
29 | contents: read
30 | security-events: write
31 |
32 | steps:
33 | - name: Checkout repository
34 | uses: actions/checkout@v4
35 |
36 | # Initializes the CodeQL tools for scanning.
37 | - name: Initialize CodeQL
38 | uses: github/codeql-action/init@v2
39 | # Override language selection by uncommenting this and choosing your languages
40 | # with:
41 | # languages: go, javascript, csharp, python, cpp, java
42 |
43 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
44 | # If this step fails, then you should remove it and run the build manually (see below).
45 | - name: Autobuild
46 | uses: github/codeql-action/autobuild@v2
47 |
48 | # ℹ️ Command-line programs to run using the OS shell.
49 | # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
50 |
51 | # ✏️ If the Autobuild fails above, remove it and uncomment the following
52 | # three lines and modify them (or add more) to build your code if your
53 | # project uses a compiled language
54 |
55 | #- run: |
56 | # make bootstrap
57 | # make release
58 |
59 | - name: Perform CodeQL Analysis
60 | uses: github/codeql-action/analyze@v2
61 |
--------------------------------------------------------------------------------
/action.yml:
--------------------------------------------------------------------------------
1 | name: Add & Commit
2 | description: Automatically commit changes made in your workflow run directly to your repo
3 |
4 | inputs:
5 | add:
6 | description: Arguments for the git add command
7 | required: false
8 | default: '.'
9 | author_name:
10 | description: The name of the user that will be displayed as the author of the commit
11 | required: false
12 | author_email:
13 | description: The email of the user that will be displayed as the author of the commit
14 | required: false
15 | commit:
16 | description: Additional arguments for the git commit command
17 | required: false
18 | committer_name:
19 | description: The name of the custom committer you want to use
20 | required: false
21 | committer_email:
22 | description: The email of the custom committer you want to use
23 | required: false
24 | cwd:
25 | description: The directory where your repository is located. You should use actions/checkout first to set it up
26 | required: false
27 | default: '.'
28 | default_author:
29 | description: How the action should fill missing author name or email.
30 | required: false
31 | default: 'github_actor'
32 | fetch:
33 | description: Arguments for the git fetch command (if 'false', the action won't fetch the repo)
34 | required: false
35 | default: --tags --force
36 | message:
37 | description: The message for the commit
38 | required: false
39 | new_branch:
40 | description: The name of the branch to create.
41 | required: false
42 | pathspec_error_handling:
43 | description: The way the action should handle pathspec errors from the add and remove commands.
44 | required: false
45 | default: ignore
46 | pull:
47 | description: Arguments for the git pull command. By default, the action does not pull.
48 | required: false
49 | push:
50 | description: Whether to push the commit and, if any, its tags to the repo. It can also be used to set the git push arguments (more info in the README)
51 | required: false
52 | default: 'true'
53 | remove:
54 | description: Arguments for the git rm command
55 | required: false
56 | tag:
57 | description: Arguments for the git tag command (the tag name always needs to be the first word not preceded by a hyphen)
58 | required: false
59 | tag_push:
60 | description: Arguments for the git push --tags command (any additional argument will be added after --tags)
61 | required: false
62 |
63 | # Input not required from the user
64 | github_token:
65 | description: The token used to make requests to the GitHub API. It's NOT used to make commits and should not be changed.
66 | required: false
67 | default: ${{ github.token }}
68 |
69 | outputs:
70 | committed:
71 | description: Whether the action has created a commit.
72 | commit_long_sha:
73 | description: The complete SHA of the commit that has been created.
74 | commit_sha:
75 | description: The short SHA of the commit that has been created.
76 | pushed:
77 | description: Whether the action has pushed to the remote.
78 | tagged:
79 | description: Whether the action has created a tag.
80 | tag_pushed:
81 | description: Whether the action has pushed a tag.
82 |
83 | runs:
84 | using: node16
85 | main: lib/index.js
86 |
87 | branding:
88 | icon: git-commit
89 | color: gray-dark
90 |
--------------------------------------------------------------------------------
/src/util.ts:
--------------------------------------------------------------------------------
1 | import { parseArgsStringToArgv } from 'string-argv'
2 | import * as core from '@actions/core'
3 | import YAML from 'js-yaml'
4 | import { Toolkit } from 'actions-toolkit'
5 | import fs from 'fs'
6 | import { input, output } from './io'
7 |
8 | type RecordOf = Record
9 | export const tools = new Toolkit, RecordOf