Compare commits
103 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e0cd865b68 | ||
|
|
ed7b74af50 | ||
|
|
8c0903ea07 | ||
|
|
29856365a6 | ||
|
|
a7661122af | ||
|
|
1181181b70 | ||
|
|
32090e561e | ||
|
|
07a46e3fca | ||
|
|
b43e3143da | ||
|
|
9c99934303 | ||
|
|
34757b89f7 | ||
|
|
e3b93a10e2 | ||
|
|
b043969cfd | ||
|
|
101829e6c0 | ||
|
|
8cd8f9f071 | ||
|
|
c010bcbe2f | ||
|
|
1b176ae96b | ||
|
|
ecdc355d15 | ||
|
|
79fae44cb3 | ||
|
|
34b3c277a4 | ||
|
|
bd911ffe7e | ||
|
|
e6f30b78b7 | ||
|
|
9145a27b50 | ||
|
|
b5dec7ea76 | ||
|
|
0c4298a18d | ||
|
|
37e118a1f5 | ||
|
|
3088d83852 | ||
|
|
3f6e296fa8 | ||
|
|
82c397024b | ||
|
|
55e3676294 | ||
|
|
cbeb36fdb1 | ||
|
|
15954de18f | ||
|
|
1d34a38003 | ||
|
|
8693022acf | ||
|
|
c7b685622a | ||
|
|
56800c1fe2 | ||
|
|
d7ef3f3a99 | ||
|
|
e9dd7a4420 | ||
|
|
f5a3783aa2 | ||
|
|
208182ae37 | ||
|
|
f7d13fceb9 | ||
|
|
360b5ee4b9 | ||
|
|
6f5455c37d | ||
|
|
4e2f1656df | ||
|
|
5348e90423 | ||
|
|
a740f7e935 | ||
|
|
590bebf249 | ||
|
|
9650af1f95 | ||
|
|
ced56a7226 | ||
|
|
a988073222 | ||
|
|
88408e5833 | ||
|
|
27a89ad786 | ||
|
|
d5f44e7aeb | ||
|
|
52f10712cb | ||
|
|
51fc21c221 | ||
|
|
46b61e173e | ||
|
|
06d54462fa | ||
|
|
21a36873cf | ||
|
|
4d2a782ca7 | ||
|
|
feb7bba5df | ||
|
|
30fd5a24e7 | ||
|
|
4f4dea335c | ||
|
|
caecee358e | ||
|
|
79fc4adbf9 | ||
|
|
4fe29d7392 | ||
|
|
2b94f96e3e | ||
|
|
ab8370c244 | ||
|
|
61eda586c3 | ||
|
|
b34850c645 | ||
|
|
f0718670ec | ||
|
|
ce9997b52f | ||
|
|
8cb387e3de | ||
|
|
4d0876f6b0 | ||
|
|
34cf82b848 | ||
|
|
8cc88cd3ac | ||
|
|
c94b5af098 | ||
|
|
d992c49843 | ||
|
|
8a80768baa | ||
|
|
8b941d4dfd | ||
|
|
d5de9f3f0d | ||
|
|
2d9c41ae6b | ||
|
|
5560eecdc1 | ||
|
|
58530b3799 | ||
|
|
026e98aa42 | ||
|
|
c2e2293f44 | ||
|
|
08fe1b6e43 | ||
|
|
46d77cfa2d | ||
|
|
8feda109a1 | ||
|
|
7e9ca065e6 | ||
|
|
7acf8aea7c | ||
|
|
30fab2fa31 | ||
|
|
cbdf3e43f1 | ||
|
|
507713a63b | ||
|
|
c512c446c5 | ||
|
|
3067c9e15c | ||
|
|
85ed07244a | ||
|
|
13550b50b0 | ||
|
|
bf3210f533 | ||
|
|
6411f389b7 | ||
|
|
dec54c038c | ||
|
|
e109cd1639 | ||
|
|
ac2b74d9d0 | ||
|
|
d82f4d33b7 |
163
.all-contributorsrc
Normal file
163
.all-contributorsrc
Normal file
@@ -0,0 +1,163 @@
|
||||
{
|
||||
"projectName": "add-and-commit",
|
||||
"projectOwner": "EndBug",
|
||||
"repoType": "github",
|
||||
"repoHost": "https://github.com",
|
||||
"files": [
|
||||
"README.md"
|
||||
],
|
||||
"imageSize": 100,
|
||||
"commit": true,
|
||||
"commitConvention": "angular",
|
||||
"contributors": [
|
||||
{
|
||||
"login": "EndBug",
|
||||
"name": "Federico Grandi",
|
||||
"avatar_url": "https://avatars1.githubusercontent.com/u/26386270?v=4",
|
||||
"profile": "https://github.com/EndBug",
|
||||
"contributions": [
|
||||
"code",
|
||||
"doc"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "jactor-rises",
|
||||
"name": "Tor Egil Jacobsen",
|
||||
"avatar_url": "https://avatars3.githubusercontent.com/u/14565088?v=4",
|
||||
"profile": "https://github.com/jactor-rises",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "yelizariev",
|
||||
"name": "Ivan Yelizariev",
|
||||
"avatar_url": "https://avatars0.githubusercontent.com/u/186131?v=4",
|
||||
"profile": "https://twitter.com/yelizariev",
|
||||
"contributions": [
|
||||
"ideas"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "jhhughes",
|
||||
"name": "jhhughes",
|
||||
"avatar_url": "https://avatars2.githubusercontent.com/u/13724293?v=4",
|
||||
"profile": "https://github.com/jhhughes",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "DmitrijOkeanij",
|
||||
"name": "Дмитрий Океаний",
|
||||
"avatar_url": "https://avatars3.githubusercontent.com/u/10674646?v=4",
|
||||
"profile": "https://sunengine.site",
|
||||
"contributions": [
|
||||
"ideas"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "brahma-dev",
|
||||
"name": "Brahma Dev",
|
||||
"avatar_url": "https://avatars3.githubusercontent.com/u/1793295?v=4",
|
||||
"profile": "https://github.com/brahma-dev",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "felixlapalma",
|
||||
"name": "Felix Rojo Lapalma",
|
||||
"avatar_url": "https://avatars2.githubusercontent.com/u/38389683?v=4",
|
||||
"profile": "https://github.com/felixlapalma",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "RobinWijnant",
|
||||
"name": "Robin Wijnant",
|
||||
"avatar_url": "https://avatars3.githubusercontent.com/u/33033209?v=4",
|
||||
"profile": "http://robinwijnant.me",
|
||||
"contributions": [
|
||||
"bug",
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "onilton",
|
||||
"name": "Onilton Maciel",
|
||||
"avatar_url": "https://avatars2.githubusercontent.com/u/725676?v=4",
|
||||
"profile": "https://github.com/onilton",
|
||||
"contributions": [
|
||||
"ideas"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "jsoref",
|
||||
"name": "Josh Soref",
|
||||
"avatar_url": "https://avatars0.githubusercontent.com/u/2119212?v=4",
|
||||
"profile": "https://github.com/jsoref",
|
||||
"contributions": [
|
||||
"doc"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "ToMe25",
|
||||
"name": "ToMe25",
|
||||
"avatar_url": "https://avatars1.githubusercontent.com/u/38815969?v=4",
|
||||
"profile": "https://github.com/ToMe25",
|
||||
"contributions": [
|
||||
"code",
|
||||
"ideas"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "JonasJacobsUserspace",
|
||||
"name": "JonasJacobsUserspace",
|
||||
"avatar_url": "https://avatars0.githubusercontent.com/u/59708720?v=4",
|
||||
"profile": "https://github.com/JonasJacobsUserspace",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "pvogt09",
|
||||
"name": "pvogt09",
|
||||
"avatar_url": "https://avatars3.githubusercontent.com/u/50047961?v=4",
|
||||
"profile": "https://github.com/pvogt09",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "connorjclark",
|
||||
"name": "Connor Clark",
|
||||
"avatar_url": "https://avatars1.githubusercontent.com/u/4071474?v=4",
|
||||
"profile": "http://hoten.cc",
|
||||
"contributions": [
|
||||
"ideas"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "Cyberbeni",
|
||||
"name": "Benedek Kozma",
|
||||
"avatar_url": "https://avatars1.githubusercontent.com/u/8356175?v=4",
|
||||
"profile": "https://github.com/Cyberbeni",
|
||||
"contributions": [
|
||||
"ideas"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "coffeegoddd",
|
||||
"name": "Dustin Brown",
|
||||
"avatar_url": "https://avatars3.githubusercontent.com/u/43383835?v=4",
|
||||
"profile": "https://github.com/coffeegoddd",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
}
|
||||
],
|
||||
"contributorsPerLine": 7,
|
||||
"skipCi": true
|
||||
}
|
||||
@@ -36,7 +36,8 @@
|
||||
"new-cap": 0,
|
||||
"no-caller": 2,
|
||||
"no-undef": 2,
|
||||
"no-unused-vars": 1,
|
||||
"no-unused-vars": 0,
|
||||
"@typescript-eslint/no-unused-vars": "warn",
|
||||
"no-empty": [
|
||||
"error",
|
||||
{
|
||||
|
||||
16
.github/dependabot.yml
vendored
Normal file
16
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
# To get started with Dependabot version updates, you'll need to specify which
|
||||
# package ecosystems to update and where the package manifests are located.
|
||||
# Please see the documentation for all configuration options:
|
||||
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: 'npm' # See documentation for possible values
|
||||
directory: '/' # Location of package manifests
|
||||
schedule:
|
||||
interval: 'weekly'
|
||||
commit-message:
|
||||
prefix: 'chore'
|
||||
include: 'scope'
|
||||
labels:
|
||||
- 'type: dependencies'
|
||||
80
.github/labels.yml
vendored
Normal file
80
.github/labels.yml
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
# General purpose
|
||||
- name: 'good first issue'
|
||||
color: '5319e7'
|
||||
description: 'Good for newcomers'
|
||||
aliases: []
|
||||
|
||||
- name: 'help wanted'
|
||||
color: '008672'
|
||||
description: 'Extra attention is needed'
|
||||
aliases: []
|
||||
|
||||
- name: 'status: pending'
|
||||
color: c5def5
|
||||
description: 'More info is needed before deciding what to do.'
|
||||
aliases: []
|
||||
|
||||
- name: 'status: pinned'
|
||||
color: 0052cc
|
||||
description: 'Issues and PRs that should not be labeled as stale or closed if they remain inactive.'
|
||||
aliases: []
|
||||
|
||||
- name: 'status: stale'
|
||||
color: fbca04
|
||||
description: 'Inactive issues and PRs.'
|
||||
aliases: ['stale']
|
||||
|
||||
- name: 'status: wontfix'
|
||||
color: ffffff
|
||||
description: 'This will not be worked on.'
|
||||
aliases: ['wontfix']
|
||||
|
||||
- name: 'type: automation'
|
||||
color: 2fc904
|
||||
description: 'About actions workflows and automation.'
|
||||
aliases: ['automation', 'actions']
|
||||
|
||||
- name: 'type: bug'
|
||||
color: d73a4a
|
||||
description: 'Verified problems that need to be worked on.'
|
||||
aliases: ['bug']
|
||||
|
||||
- name: 'type: dependencies'
|
||||
color: 0366d6
|
||||
description: 'Pull requests that update a dependency file'
|
||||
aliases: ['dependencies']
|
||||
|
||||
- name: 'type: duplicate'
|
||||
color: cfd3d7
|
||||
description: 'This issue or pull request already exists.'
|
||||
aliases: ['duplicate']
|
||||
|
||||
- name: 'type: enhancement'
|
||||
color: a2eeef
|
||||
description: 'New feature or request.'
|
||||
aliases: ['enhancement']
|
||||
|
||||
- name: 'type: invalid'
|
||||
color: e4e669
|
||||
description: "This doesn't seem right."
|
||||
aliases: ['invalid']
|
||||
|
||||
- name: 'type: maintenance'
|
||||
color: 0075ca
|
||||
description: "Documentation improvements and code refactoring, doesn't affect functionality."
|
||||
aliases: ['documentation', 'docs']
|
||||
|
||||
- name: 'type: not a bug'
|
||||
color: 0e8a16
|
||||
description: 'Reports that happen not be our fault.'
|
||||
aliases: ['not a bug']
|
||||
|
||||
- name: 'type: question'
|
||||
color: d876e3
|
||||
description: 'Further information is requested.'
|
||||
aliases: ['question']
|
||||
|
||||
- name: 'type: security'
|
||||
color: 'ee0701'
|
||||
description: 'Pull requests that address a security vulnerability.'
|
||||
aliases: ['security']
|
||||
28
.github/workflows/build.yml
vendored
28
.github/workflows/build.yml
vendored
@@ -1,36 +1,36 @@
|
||||
name: Build
|
||||
on:
|
||||
push:
|
||||
branches-ignore:
|
||||
- dist
|
||||
paths:
|
||||
- src/**
|
||||
- .github/workflows/build.yml
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build compiled JS version
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v1
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 12.x
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
- run: npm install
|
||||
|
||||
- name: Compile TypeScript into compressed JavaScript
|
||||
run: npm run build
|
||||
- run: npm run build
|
||||
|
||||
- name: Commit changes
|
||||
uses: EndBug/add-and-commit@v4.0.0
|
||||
- uses: EndBug/add-and-commit@v4
|
||||
with:
|
||||
message: "[auto] Update compiled version"
|
||||
message: '[auto] build: update compiled version'
|
||||
add: lib
|
||||
force: true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- uses: EndBug/add-and-commit@v4
|
||||
with:
|
||||
message: '[auto] build: update input typings'
|
||||
add: src/inputs.ts
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
29
.github/workflows/docs.yml
vendored
Normal file
29
.github/workflows/docs.yml
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
name: Docs
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- .all-contributorsrc
|
||||
- .github/workflows/docs.yml
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
contributors:
|
||||
name: Update contributors badge
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 12.x
|
||||
|
||||
- run: npm install
|
||||
|
||||
- run: npm run all-contributors-badge
|
||||
|
||||
- uses: EndBug/add-and-commit@v4.0.0
|
||||
with:
|
||||
message: "[auto] docs: update contributors badge"
|
||||
add: README.md
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
21
.github/workflows/export-labels.yml
vendored
Normal file
21
.github/workflows/export-labels.yml
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
name: Export label config
|
||||
on:
|
||||
# You can run this with every event, but it's better to run it only when you actually need it.
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
labels:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: EndBug/export-label-config@main
|
||||
with:
|
||||
# This is needed if you're dealing with private repos.
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# Set this to `true` if you want to get the raw API reponse. Defaults to `false`.
|
||||
raw-result: false
|
||||
|
||||
# By default every label entry will have an `aliases` property set to an empty array.
|
||||
# It's for EndBug/label-sync, if you don't want it you cans set this to `false`
|
||||
add-aliases: true
|
||||
17
.github/workflows/label-sync.yml
vendored
Normal file
17
.github/workflows/label-sync.yml
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
name: Sync labels
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '.github/labels.yml'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
sync:
|
||||
name: Run EndBug/label-sync
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: EndBug/label-sync@v1
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
config-file: '.github/labels.yml'
|
||||
21
.github/workflows/stale.yml
vendored
Normal file
21
.github/workflows/stale.yml
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
name: 'Handle stale issues and PRs'
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 0 * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@v3
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
stale-issue-message: 'This issue is being marked as "stale" because it has been open 20 days with no activity. Remove the "stale" label or comment, otherwise this will be closed in 5 days.'
|
||||
stale-issue-label: 'status: stale'
|
||||
exempt-issue-labels: 'status: pinned'
|
||||
stale-pr-message: 'This PR is being marked as "stale" because it has been open 20 days with no activity. Remove the "stale" label or comment, otherwise this will be closed in 5 days.'
|
||||
stale-pr-label: 'status: stale'
|
||||
exempt-pr-labels: 'status: pinned'
|
||||
days-before-stale: 20
|
||||
days-before-close: 5
|
||||
2
.github/workflows/versioning.yml
vendored
2
.github/workflows/versioning.yml
vendored
@@ -8,7 +8,7 @@ jobs:
|
||||
actions-tagger:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: Actions-R-Us/actions-tagger@latest
|
||||
- uses: Actions-R-Us/actions-tagger@v1
|
||||
with:
|
||||
publish_latest: true
|
||||
env:
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,2 @@
|
||||
node_modules
|
||||
build
|
||||
lib
|
||||
|
||||
141
CHANGELOG.md
Normal file
141
CHANGELOG.md
Normal file
@@ -0,0 +1,141 @@
|
||||
# Changelog
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [5.1.1] - 2020-11-07
|
||||
### Fixed:
|
||||
- Fixed typo in parameter name: `pull_strategy` was written as `pull_stategy` (PR #83)
|
||||
|
||||
## [5.1.0] - 2020-10-07
|
||||
### Added:
|
||||
- The default commit message now displays the name of the workflow too (issue #64)
|
||||
|
||||
## [5.0.0] - 2020-09-27
|
||||
### Changed:
|
||||
- **[BREAKING]** Action parameters: multiple action parameters have been changed, refer to the docs for better info
|
||||
- The code is now entirely in TypeScript (PR #57)
|
||||
|
||||
### Fixed:
|
||||
- Improved input checks
|
||||
- Logs are now displayed on Windows too
|
||||
- Remove unnecessary steps
|
||||
- Remove unused dependencies
|
||||
|
||||
## [4.4.0] - 2020-07-31
|
||||
### Added:
|
||||
- Pull requests: the action can now work in runs triggered by pull request events (issue #48)
|
||||
|
||||
## [4.3.0] - 2020-07-29
|
||||
### Addded:
|
||||
- `signoff` parameter: lets you use the `--signoff` argument for the `git commit` command (PR #46)
|
||||
|
||||
## [4.2.1] - 2020-07-10
|
||||
### Fixed:
|
||||
- OS-support: the action now properly works on Windows instances (issue #33)
|
||||
|
||||
## [4.2.0] - 2020-05-17
|
||||
### Added:
|
||||
- Tagging: you can now create and update lightweight tags (PR #30)
|
||||
|
||||
## [4.1.0] - 2020-05-01
|
||||
### Added:
|
||||
- `ref` parameter: lets you choose the branch to run the action on, the default is the one that triggered the workflow (issue #29)
|
||||
|
||||
## [4.0.3] - 2020-05-01
|
||||
### Fixed:
|
||||
- Logs: `git diff` won't display logs anymore, to avoid buffer problems (issue #27)
|
||||
- Logs: additional info will be logged along with the command outputs
|
||||
- Logs: added groups to improve readability
|
||||
|
||||
## [4.0.2] - 2020-04-19
|
||||
### Fixed:
|
||||
- Error handling: failures are now easier to read (issue #25)
|
||||
|
||||
## [4.0.1] - 2020-03-20
|
||||
### Fixed:
|
||||
- Scheduled events: the action can be used in action runs triggered by a scheduled events
|
||||
- Warnings: there won't be warnings when both `author_name` and `author_email` are set
|
||||
|
||||
## [4.0.0] - 2020-03-03
|
||||
### Removed:
|
||||
- **[BREAKING]** `path` parameter: see 'Changed' section for more info
|
||||
- **[BREAKING]** `pattern` parameter: see 'Changed' section for more info
|
||||
|
||||
### Changed:
|
||||
- The action now uses `git add` and `git rm` commands, you can choose their arguemnts directly by using the `add` and `remove` parameters
|
||||
- **[BREAKING]** Error handling: the action won't stop if one of your git commands fails (e.g. if one of your pathspecs doesn't match any file)
|
||||
|
||||
## [3.1.0] - 2020-02-21
|
||||
### Added:
|
||||
- `remove` parameter: lets you delete files directly from the action
|
||||
|
||||
## [3.0.0] - 2020-01-24
|
||||
### Added:
|
||||
- The action can now run in multiple subsequent jobs in the same workflow
|
||||
|
||||
### Removed:
|
||||
- **[BREAKING]** [`actions/checkout@v1`](https://github.com/actions/checkout/tree/v1) support is being dropped in favor of [`actions/checkout@v2`](https://github.com/actions/checkout/releases/tag/v2)
|
||||
|
||||
## [2.3.2] - 2019-12-29
|
||||
### Added:
|
||||
- `cwd` parameter: lets you set the Current Working Directory
|
||||
|
||||
## [2.3.1] - 2019-12-20
|
||||
### Added:
|
||||
- Short tags: from now on, there will be short major tags available (`v2`, `v3`, ...)
|
||||
|
||||
## [2.3.0] - 2019-12-14
|
||||
### Changed:
|
||||
- TypeScript rewrite: the action will run faster because, unlike with Docker, no build process is needed
|
||||
|
||||
### Added:
|
||||
- OS support: the action can now run in non-Linux environments too
|
||||
|
||||
## [2.2.0] - 2019-12-14
|
||||
### Added:
|
||||
- The action can automatically fetch the commit author to use
|
||||
- You can manually provide the author using the `author_name` and `author_email` parameters
|
||||
|
||||
## [2.1.1] - 2019-12-07
|
||||
### Fixed:
|
||||
- The action can now be used multiple times in the same workflow
|
||||
|
||||
## [2.1.0] - 2019-09-19
|
||||
### Added:
|
||||
- `force` parameter: uses `--force` when running `git add`
|
||||
|
||||
## [2.0.0] - 2019-09-18
|
||||
### Changed:
|
||||
- **[BREAKING]** The action now uses a `find` command
|
||||
|
||||
## [1.0.0] - 2019-09-17
|
||||
First release
|
||||
|
||||
#
|
||||
[Unreleased]: https://github.com/EndBug/add-and-commit/compare/v5.1.1...HEAD
|
||||
[1.0.0]: https://github.com/EndBug/add-and-commit/tree/v1.0.0
|
||||
[2.0.0]: https://github.com/EndBug/add-and-commit/compare/v1.0.0...v2.0.0
|
||||
[2.1.0]: https://github.com/EndBug/add-and-commit/compare/v2.0.0...v2.1.0
|
||||
[2.1.1]: https://github.com/EndBug/add-and-commit/compare/v2.1.0...v2.1.1
|
||||
[2.2.0]: https://github.com/EndBug/add-and-commit/compare/v2.1.1...v2.2.0
|
||||
[2.3.0]: https://github.com/EndBug/add-and-commit/compare/v2.2.0...v2.3.0
|
||||
[2.3.1]: https://github.com/EndBug/add-and-commit/compare/v2.3.0...v2.3.1
|
||||
[2.3.2]: https://github.com/EndBug/add-and-commit/compare/v2.3.1...v2.3.2
|
||||
[3.0.0]: https://github.com/EndBug/add-and-commit/compare/v2.3.2...v3.0.0
|
||||
[3.1.0]: https://github.com/EndBug/add-and-commit/compare/v3.0.0...v3.1.0
|
||||
[4.0.0]: https://github.com/EndBug/add-and-commit/compare/v3.1.0...v4.0.0
|
||||
[4.0.1]: https://github.com/EndBug/add-and-commit/compare/v4.0.0...v4.0.1
|
||||
[4.0.2]: https://github.com/EndBug/add-and-commit/compare/v4.0.1...v4.0.2
|
||||
[4.0.3]: https://github.com/EndBug/add-and-commit/compare/v4.0.2...v4.0.3
|
||||
[4.1.0]: https://github.com/EndBug/add-and-commit/compare/v4.0.3...v4.1.0
|
||||
[4.2.0]: https://github.com/EndBug/add-and-commit/compare/v4.1.0...v4.2.0
|
||||
[4.2.1]: https://github.com/EndBug/add-and-commit/compare/v4.2.0...v4.2.1
|
||||
[4.3.0]: https://github.com/EndBug/add-and-commit/compare/v4.2.1...v4.3.0
|
||||
[4.4.0]: https://github.com/EndBug/add-and-commit/compare/v4.3.0...v4.4.0
|
||||
[5.0.0]: https://github.com/EndBug/add-and-commit/compare/v4.4.0...v5.0.0
|
||||
[5.1.0]: https://github.com/EndBug/add-and-commit/compare/v5.0.0...v5.1.0
|
||||
[5.1.1]: https://github.com/EndBug/add-and-commit/compare/v5.1.0...v5.1.1
|
||||
80
README.md
80
README.md
@@ -1,4 +1,6 @@
|
||||
# Add & Commit
|
||||
<a href="https://github.com/search?o=desc&q=EndBug%2Fadd-and-commit+path%3A.github%2Fworkflows+language%3AYAML&s=&type=Code" target="_blank" title="Public workflows that use this action."><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fapi-git-master.endbug.vercel.app%2Fapi%2Fgithub-actions%2Fused-by%3Faction%3DEndBug%2Fadd-and-commit%26badge%3Dtrue" alt="Public workflows that use this action."></a>
|
||||
[](#contributors-)
|
||||
|
||||
You can use this GitHub Action to commit changes made in your workflow run directly to your repo: for example, you use it to lint your code, update documentation, commit updated builds, etc....
|
||||
|
||||
@@ -10,7 +12,7 @@ This action lets you choose the path that you want to use when adding & committi
|
||||
Add a step like this to your workflow:
|
||||
|
||||
```yaml
|
||||
- uses: EndBug/add-and-commit@v4 # You can change this to use a specific version
|
||||
- uses: EndBug/add-and-commit@v5 # You can change this to use a specific version
|
||||
with:
|
||||
# The arguments for the `git add` command (see the paragraph below for more info)
|
||||
# Default: '.'
|
||||
@@ -24,29 +26,33 @@ Add a step like this to your workflow:
|
||||
# Default: author of the commit that triggered the run
|
||||
author_email: mail@example.com
|
||||
|
||||
# Name of the branch to use, if different from the one that triggered the workflow
|
||||
# Default: the branch that triggered the run
|
||||
branch: some-branch
|
||||
|
||||
# The local path to the directory where your repository is located. You should use actions/checkout first to set it up
|
||||
# Default: '.'
|
||||
cwd: './path/to/the/repo'
|
||||
|
||||
# Whether to use the --force option on `git add`, in order to bypass eventual gitignores
|
||||
# Default: false
|
||||
force: true
|
||||
|
||||
# The message for the commit
|
||||
# Default: 'Commit from GitHub Actions'
|
||||
# Default: 'Commit from GitHub Actions (name of the workflow)'
|
||||
message: 'Your commit message'
|
||||
|
||||
# Name of the branch to use, if different from the one that triggered the workflow
|
||||
# Default: the branch that triggered the workflow (from GITHUB_REF)
|
||||
ref: 'someOtherBranch'
|
||||
# The flag used on the pull strategy
|
||||
# Default: '--no-rebase'
|
||||
pull_strategy: '--no-rebase or --no-ff or --rebase'
|
||||
|
||||
# The arguments for the `git rm` command (see the paragraph below for more info)
|
||||
# Default: ''
|
||||
remove: "./dir/old_file.js"
|
||||
|
||||
# Name of the tag to add to the new commit (see the paragraph below for more info)
|
||||
# Whether to use the --signoff option on `git commit` (only `true` and `false` are accepted)
|
||||
# Default: false
|
||||
signoff: true
|
||||
|
||||
# Arguments for the git tag command (the tag name always needs to be the first word not preceded by an hyphen)
|
||||
# Default: ''
|
||||
tag: "v1.0.0"
|
||||
tag: "v1.0.0 --force"
|
||||
|
||||
env:
|
||||
# This is necessary in order to push a commit to the repo
|
||||
@@ -60,18 +66,17 @@ That said, you can just copy the example line and not worry about it. If you do
|
||||
|
||||
### Adding files:
|
||||
|
||||
The action adds files using a regular `git add` command, so you can put every kind of argument in the `add` option. For example, if you don't want it to use a recursive behavior: `$(find . -maxdepth 1 -name *.js)`.
|
||||
The action adds files using a regular `git add` command, so you can put every kind of argument in the `add` option. For example, if you want to force-add a file: `./path/to/file.txt --force`.
|
||||
The script will not stop if one of the git commands fails. E.g.: if your command shows a "fatal: pathspec 'yourFile' did not match any files" error the action will go on.
|
||||
|
||||
### Deleting files:
|
||||
|
||||
You can delete files with the `remove` option: that runs a `git rm` command that will stage the files in the given path for removal.
|
||||
You can delete files with the `remove` option: that runs a `git rm` command that will stage the files in the given path for removal. As with the `add` argument, you can use every option `git rm` allows (e.g. add `--force` to ignore `.gitignore` rules).
|
||||
The script will not stop if one of the git commands fails. E.g.: if your command shows a "fatal: pathspec 'yourFile' did not match any files" error the action will go on.
|
||||
|
||||
### Tagging:
|
||||
|
||||
You can tag commits with the `tag` option: when used, it will create a lightweight tag for the commit with the name you set as input. If not entered (or if an empty string is passed) teh action won't create any tag.
|
||||
If there is already a tag with the name you entered it will be overwritten, and so the tag will be "updated".
|
||||
You can use the `tag` option to enter the arguments for a `git add` command. In order for the action to isolate the tag name from the rest of the arguments, it should be the first word not preceded by an hyphen (e.g. `-a tag-name -m "some other stuff"` is ok).
|
||||
|
||||
### Examples:
|
||||
|
||||
@@ -101,7 +106,7 @@ jobs:
|
||||
run: eslint "src/**" --fix
|
||||
|
||||
- name: Commit changes
|
||||
uses: EndBug/add-and-commit@v4
|
||||
uses: EndBug/add-and-commit@v5
|
||||
with:
|
||||
author_name: Your Name
|
||||
author_email: mail@example.com
|
||||
@@ -132,16 +137,53 @@ jobs:
|
||||
- run: echo "123" > ./pathToRepo/file.txt
|
||||
|
||||
# ...and then use the action as you would normally do, but providing the path to the repo
|
||||
- uses: EndBug/add-and-commit@v4
|
||||
- uses: EndBug/add-and-commit@v5
|
||||
with:
|
||||
message: "Add the very useful text file"
|
||||
add: "*.txt"
|
||||
add: "*.txt --force"
|
||||
cwd: "./pathToRepo/"
|
||||
force: true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
## Contributors ✨
|
||||
|
||||
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
||||
|
||||
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
||||
<!-- prettier-ignore-start -->
|
||||
<!-- markdownlint-disable -->
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center"><a href="https://github.com/EndBug"><img src="https://avatars1.githubusercontent.com/u/26386270?v=4" width="100px;" alt=""/><br /><sub><b>Federico Grandi</b></sub></a><br /><a href="https://github.com/EndBug/add-and-commit/commits?author=EndBug" title="Code">💻</a> <a href="https://github.com/EndBug/add-and-commit/commits?author=EndBug" title="Documentation">📖</a></td>
|
||||
<td align="center"><a href="https://github.com/jactor-rises"><img src="https://avatars3.githubusercontent.com/u/14565088?v=4" width="100px;" alt=""/><br /><sub><b>Tor Egil Jacobsen</b></sub></a><br /><a href="https://github.com/EndBug/add-and-commit/commits?author=jactor-rises" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://twitter.com/yelizariev"><img src="https://avatars0.githubusercontent.com/u/186131?v=4" width="100px;" alt=""/><br /><sub><b>Ivan Yelizariev</b></sub></a><br /><a href="#ideas-yelizariev" title="Ideas, Planning, & Feedback">🤔</a></td>
|
||||
<td align="center"><a href="https://github.com/jhhughes"><img src="https://avatars2.githubusercontent.com/u/13724293?v=4" width="100px;" alt=""/><br /><sub><b>jhhughes</b></sub></a><br /><a href="https://github.com/EndBug/add-and-commit/issues?q=author%3Ajhhughes" title="Bug reports">🐛</a></td>
|
||||
<td align="center"><a href="https://sunengine.site"><img src="https://avatars3.githubusercontent.com/u/10674646?v=4" width="100px;" alt=""/><br /><sub><b>Дмитрий Океаний</b></sub></a><br /><a href="#ideas-DmitrijOkeanij" title="Ideas, Planning, & Feedback">🤔</a></td>
|
||||
<td align="center"><a href="https://github.com/brahma-dev"><img src="https://avatars3.githubusercontent.com/u/1793295?v=4" width="100px;" alt=""/><br /><sub><b>Brahma Dev</b></sub></a><br /><a href="https://github.com/EndBug/add-and-commit/issues?q=author%3Abrahma-dev" title="Bug reports">🐛</a></td>
|
||||
<td align="center"><a href="https://github.com/felixlapalma"><img src="https://avatars2.githubusercontent.com/u/38389683?v=4" width="100px;" alt=""/><br /><sub><b>Felix Rojo Lapalma</b></sub></a><br /><a href="https://github.com/EndBug/add-and-commit/issues?q=author%3Afelixlapalma" title="Bug reports">🐛</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><a href="http://robinwijnant.me"><img src="https://avatars3.githubusercontent.com/u/33033209?v=4" width="100px;" alt=""/><br /><sub><b>Robin Wijnant</b></sub></a><br /><a href="https://github.com/EndBug/add-and-commit/issues?q=author%3ARobinWijnant" title="Bug reports">🐛</a> <a href="https://github.com/EndBug/add-and-commit/commits?author=RobinWijnant" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/onilton"><img src="https://avatars2.githubusercontent.com/u/725676?v=4" width="100px;" alt=""/><br /><sub><b>Onilton Maciel</b></sub></a><br /><a href="#ideas-onilton" title="Ideas, Planning, & Feedback">🤔</a></td>
|
||||
<td align="center"><a href="https://github.com/jsoref"><img src="https://avatars0.githubusercontent.com/u/2119212?v=4" width="100px;" alt=""/><br /><sub><b>Josh Soref</b></sub></a><br /><a href="https://github.com/EndBug/add-and-commit/commits?author=jsoref" title="Documentation">📖</a></td>
|
||||
<td align="center"><a href="https://github.com/ToMe25"><img src="https://avatars1.githubusercontent.com/u/38815969?v=4" width="100px;" alt=""/><br /><sub><b>ToMe25</b></sub></a><br /><a href="https://github.com/EndBug/add-and-commit/commits?author=ToMe25" title="Code">💻</a> <a href="#ideas-ToMe25" title="Ideas, Planning, & Feedback">🤔</a></td>
|
||||
<td align="center"><a href="https://github.com/JonasJacobsUserspace"><img src="https://avatars0.githubusercontent.com/u/59708720?v=4" width="100px;" alt=""/><br /><sub><b>JonasJacobsUserspace</b></sub></a><br /><a href="https://github.com/EndBug/add-and-commit/issues?q=author%3AJonasJacobsUserspace" title="Bug reports">🐛</a></td>
|
||||
<td align="center"><a href="https://github.com/pvogt09"><img src="https://avatars3.githubusercontent.com/u/50047961?v=4" width="100px;" alt=""/><br /><sub><b>pvogt09</b></sub></a><br /><a href="https://github.com/EndBug/add-and-commit/commits?author=pvogt09" title="Code">💻</a></td>
|
||||
<td align="center"><a href="http://hoten.cc"><img src="https://avatars1.githubusercontent.com/u/4071474?v=4" width="100px;" alt=""/><br /><sub><b>Connor Clark</b></sub></a><br /><a href="#ideas-connorjclark" title="Ideas, Planning, & Feedback">🤔</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><a href="https://github.com/Cyberbeni"><img src="https://avatars1.githubusercontent.com/u/8356175?v=4" width="100px;" alt=""/><br /><sub><b>Benedek Kozma</b></sub></a><br /><a href="#ideas-Cyberbeni" title="Ideas, Planning, & Feedback">🤔</a></td>
|
||||
<td align="center"><a href="https://github.com/coffeegoddd"><img src="https://avatars3.githubusercontent.com/u/43383835?v=4" width="100px;" alt=""/><br /><sub><b>Dustin Brown</b></sub></a><br /><a href="https://github.com/EndBug/add-and-commit/issues?q=author%3Acoffeegoddd" title="Bug reports">🐛</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<!-- markdownlint-enable -->
|
||||
<!-- prettier-ignore-end -->
|
||||
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
||||
|
||||
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
|
||||
|
||||
## License
|
||||
|
||||
This action is distributed under the MIT license, check the [license](LICENSE) for more info.
|
||||
|
||||
26
action.yml
26
action.yml
@@ -5,36 +5,36 @@ inputs:
|
||||
add:
|
||||
description: Arguments for the git add command
|
||||
required: false
|
||||
default: "."
|
||||
default: '.'
|
||||
author_name:
|
||||
description: The name of the user that will be displayed as the author of the commit
|
||||
required: false
|
||||
author_email:
|
||||
description: The email of the user that will be displayed as the author of the commit
|
||||
required: false
|
||||
branch:
|
||||
description: Name of the branch to use, if different from the one that triggered the workflow
|
||||
required: false
|
||||
cwd:
|
||||
description: The directory where your repository is located. You should use actions/checkout first to set it up
|
||||
required: false
|
||||
default: "."
|
||||
force:
|
||||
description: Whether to use the force option on git add, in order to bypass eventual gitignores
|
||||
required: false
|
||||
default: "false"
|
||||
default: '.'
|
||||
message:
|
||||
description: The message for the commit
|
||||
required: false
|
||||
default: Commit from GitHub Actions
|
||||
ref:
|
||||
description: Name of the branch to use, if different from the one that triggered the workflow
|
||||
pull_strategy:
|
||||
description: The flag used on the pull strategy
|
||||
required: false
|
||||
default: '--no-rebase'
|
||||
remove:
|
||||
description: Arguments for the git rm command
|
||||
required: false
|
||||
default: ""
|
||||
tag:
|
||||
description: The name of the tag to add to the new commit
|
||||
signoff:
|
||||
description: Whether to use the --signoff option on git commit
|
||||
required: false
|
||||
tag:
|
||||
description: Arguments for the git tag command (the tag name always needs to be the first word not preceded by a hyphen)
|
||||
required: false
|
||||
default: ""
|
||||
|
||||
runs:
|
||||
using: node12
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -u
|
||||
|
||||
echo "::group::Internal logs"
|
||||
|
||||
cd $INPUT_CWD
|
||||
echo "Running in $PWD."
|
||||
|
||||
# Set up .netrc file with GitHub credentials
|
||||
git_setup() {
|
||||
cat <<-EOF >$HOME/.netrc
|
||||
machine github.com
|
||||
login $GITHUB_ACTOR
|
||||
password $GITHUB_TOKEN
|
||||
|
||||
machine api.github.com
|
||||
login $GITHUB_ACTOR
|
||||
password $GITHUB_TOKEN
|
||||
EOF
|
||||
chmod 600 $HOME/.netrc
|
||||
git config --global user.email "$INPUT_AUTHOR_EMAIL"
|
||||
git config --global user.name "$INPUT_AUTHOR_NAME"
|
||||
}
|
||||
|
||||
add() {
|
||||
if $INPUT_FORCE; then f=-f; else f=; fi
|
||||
git add $INPUT_ADD $f
|
||||
}
|
||||
|
||||
remove() {
|
||||
if [ -n "$INPUT_REMOVE" ]; then git rm $INPUT_REMOVE; fi
|
||||
}
|
||||
|
||||
tag() {
|
||||
if [ -n "$INPUT_TAG" ]; then git tag $INPUT_TAG; fi
|
||||
}
|
||||
|
||||
# This is needed to make the check work for untracked files
|
||||
echo "Staging files..."
|
||||
add
|
||||
remove
|
||||
|
||||
echo "Checking for uncommitted changes in the git working tree..."
|
||||
# This section only runs if there have been file changes
|
||||
if ! git diff --cached --quiet --exit-code; then
|
||||
git_setup
|
||||
|
||||
git fetch
|
||||
|
||||
# Verify if the branch needs to be created
|
||||
if ! git rev-parse --verify --quiet "$INPUT_REF"; then
|
||||
echo "Creating branch..."
|
||||
git branch "$INPUT_REF"
|
||||
fi
|
||||
|
||||
# Switch to branch from current workflow run
|
||||
echo "Switching branch..."
|
||||
git checkout "$INPUT_REF"
|
||||
|
||||
echo "Pulling from remote..."
|
||||
git fetch && git pull
|
||||
|
||||
echo "Resetting files..."
|
||||
git reset
|
||||
|
||||
echo "Adding files..."
|
||||
add
|
||||
|
||||
echo "Removing files..."
|
||||
remove
|
||||
|
||||
echo "Creating commit..."
|
||||
git commit -m "$INPUT_MESSAGE" --author="$INPUT_AUTHOR_NAME <$INPUT_AUTHOR_EMAIL>"
|
||||
|
||||
echo "Tagging commit..."
|
||||
tag
|
||||
|
||||
echo "Pushing commits to repo..."
|
||||
git push --set-upstream origin "$INPUT_REF"
|
||||
|
||||
echo "Pushing tags to repo..."
|
||||
git push --set-upstream origin "$INPUT_REF" --force --tags
|
||||
|
||||
echo "::endgroup::"
|
||||
echo "Task completed."
|
||||
else
|
||||
echo "::endgroup::"
|
||||
echo "Working tree clean. Nothing to commit."
|
||||
fi
|
||||
File diff suppressed because one or more lines are too long
827
package-lock.json
generated
827
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
32
package.json
32
package.json
@@ -1,13 +1,21 @@
|
||||
{
|
||||
"name": "add-and-commit",
|
||||
"version": "4.2.0",
|
||||
"version": "5.1.1",
|
||||
"description": "Add & commit files from a path directly from GitHub Actions",
|
||||
"main": "lib/index.js",
|
||||
"scripts": {
|
||||
"build": "npm i && ncc build src/main.ts --minify --out lib",
|
||||
"build": "npm run inputs && ncc build src/main.ts --minify --out lib",
|
||||
"watch": "ncc build src/main.ts --watch --out lib",
|
||||
"all-contributors-badge": "ts-node scripts/all-contributors-badge",
|
||||
"changelog": "ts-node scripts/changelog.ts",
|
||||
"inputs": "ts-node scripts/inputs.ts",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "npm run build && git add src lib"
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/EndBug/add-and-commit.git"
|
||||
@@ -26,15 +34,21 @@
|
||||
},
|
||||
"homepage": "https://github.com/EndBug/add-and-commit#readme",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.1.3"
|
||||
"@actions/core": "^1.2.6",
|
||||
"axios": "^0.21.0",
|
||||
"simple-git": "^2.21.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^12.7.12",
|
||||
"@types/shelljs": "^0.8.6",
|
||||
"@typescript-eslint/eslint-plugin": "^2.12.0",
|
||||
"@typescript-eslint/parser": "^2.12.0",
|
||||
"@zeit/ncc": "^0.21.1",
|
||||
"@types/node": "^12.12.54",
|
||||
"@types/yamljs": "^0.2.31",
|
||||
"@typescript-eslint/eslint-plugin": "^2.34.0",
|
||||
"@typescript-eslint/parser": "^2.34.0",
|
||||
"@vercel/ncc": "^0.24.1",
|
||||
"all-contributors-cli": "^6.19.0",
|
||||
"eslint": "^6.8.0",
|
||||
"typescript": "^3.6.4"
|
||||
"husky": "^4.3.0",
|
||||
"ts-node": "^9.0.0",
|
||||
"typescript": "^4.0.5",
|
||||
"yamljs": "^0.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
20
scripts/all-contributors-badge.ts
Normal file
20
scripts/all-contributors-badge.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import * as fs from 'fs'
|
||||
import { resolve } from 'path'
|
||||
|
||||
function path(...segments: string[]) {
|
||||
return resolve(__dirname, '..', ...segments)
|
||||
}
|
||||
|
||||
const README = fs.readFileSync(path('README.md'), { encoding: 'utf8' }),
|
||||
{ contributors } = JSON.parse(fs.readFileSync(path('.all-contributorsrc'), { encoding: 'utf8' }))
|
||||
if (!(contributors instanceof Array)) throw new Error('Invalid config file')
|
||||
|
||||
const updatedREADME = README
|
||||
.split('\n')
|
||||
.map(line =>
|
||||
line.startsWith('[
|
||||
? `[](#contributors-)`
|
||||
: line
|
||||
).join('\n')
|
||||
|
||||
fs.writeFileSync(path('README.md'), updatedREADME)
|
||||
44
scripts/changelog.ts
Normal file
44
scripts/changelog.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
|
||||
const currentVersion = require('../package.json').version
|
||||
if (!currentVersion) throw new Error('Cant\'t detect library version.')
|
||||
|
||||
const changelogPath = path.resolve(__dirname, '../CHANGELOG.md')
|
||||
const changelog = fs.readFileSync(changelogPath, { encoding: 'utf-8' })
|
||||
if (changelog.includes(`## [${currentVersion}]`))
|
||||
throw new Error('Current version has already been documented.')
|
||||
let futureChangelog = ''
|
||||
|
||||
// Add version section
|
||||
let arr = changelog.split('## [Unreleased]')
|
||||
arr[1] = `
|
||||
|
||||
## [${currentVersion}] - ${new Date().toISOString().slice(0, 10)}
|
||||
### Removed:
|
||||
- **[BREAKING]** ListName: description
|
||||
|
||||
### Added:
|
||||
-
|
||||
|
||||
### Fixed:
|
||||
- ` + arr[1]
|
||||
futureChangelog = arr.join('## [Unreleased]')
|
||||
|
||||
// Update footer
|
||||
arr = futureChangelog
|
||||
.split('\n')
|
||||
.map(line => line.startsWith('[Unreleased]')
|
||||
? `[Unreleased]: https://github.com/EndBug/add-and-commit/compare/v${currentVersion}...HEAD`
|
||||
: line)
|
||||
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
const lastVersion = ([...arr].reverse()[1]?.match(/\[([^\][]*)]/) || [])[0].replace(/[\[\]']+/g, '')
|
||||
if (!lastVersion) throw new Error('Can\'t find last version in changelog.')
|
||||
|
||||
const lastLine = `[${currentVersion}]: https://github.com/EndBug/add-and-commit/compare/v${lastVersion}...v${currentVersion}`
|
||||
if (arr[arr.length - 1] === '') arr[arr.length - 1] = lastLine
|
||||
else arr.push(lastLine)
|
||||
futureChangelog = arr.join('\n')
|
||||
|
||||
fs.writeFileSync(changelogPath, futureChangelog)
|
||||
11
scripts/inputs.ts
Normal file
11
scripts/inputs.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import YAML from 'yamljs'
|
||||
import fs from 'fs'
|
||||
|
||||
const actionManifest = YAML.load('action.yml'),
|
||||
inputs = Object.keys(actionManifest?.inputs || {})
|
||||
|
||||
fs.writeFileSync('src/inputs.ts', `
|
||||
// WARNING: this file is auto-generated by scripts/inputs.ts (npm run inputs), any manual edit will be overwritten.
|
||||
|
||||
export type Input = ${inputs.map(s => `'${s}'`).join(' | ')}
|
||||
`.trimLeft())
|
||||
@@ -1,89 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -u
|
||||
|
||||
echo "::group::Internal logs"
|
||||
|
||||
cd $INPUT_CWD
|
||||
echo "Running in $PWD."
|
||||
|
||||
# Set up .netrc file with GitHub credentials
|
||||
git_setup() {
|
||||
cat <<-EOF >$HOME/.netrc
|
||||
machine github.com
|
||||
login $GITHUB_ACTOR
|
||||
password $GITHUB_TOKEN
|
||||
|
||||
machine api.github.com
|
||||
login $GITHUB_ACTOR
|
||||
password $GITHUB_TOKEN
|
||||
EOF
|
||||
chmod 600 $HOME/.netrc
|
||||
git config --global user.email "$INPUT_AUTHOR_EMAIL"
|
||||
git config --global user.name "$INPUT_AUTHOR_NAME"
|
||||
}
|
||||
|
||||
add() {
|
||||
if $INPUT_FORCE; then f=-f; else f=; fi
|
||||
git add $INPUT_ADD $f
|
||||
}
|
||||
|
||||
remove() {
|
||||
if [ -n "$INPUT_REMOVE" ]; then git rm $INPUT_REMOVE; fi
|
||||
}
|
||||
|
||||
tag() {
|
||||
if [ -n "$INPUT_TAG" ]; then git tag $INPUT_TAG; fi
|
||||
}
|
||||
|
||||
# This is needed to make the check work for untracked files
|
||||
echo "Staging files..."
|
||||
add
|
||||
remove
|
||||
|
||||
echo "Checking for uncommitted changes in the git working tree..."
|
||||
# This section only runs if there have been file changes
|
||||
if ! git diff --cached --quiet --exit-code; then
|
||||
git_setup
|
||||
|
||||
git fetch
|
||||
|
||||
# Verify if the branch needs to be created
|
||||
if ! git rev-parse --verify --quiet "$INPUT_REF"; then
|
||||
echo "Creating branch..."
|
||||
git branch "$INPUT_REF"
|
||||
fi
|
||||
|
||||
# Switch to branch from current workflow run
|
||||
echo "Switching branch..."
|
||||
git checkout "$INPUT_REF"
|
||||
|
||||
echo "Pulling from remote..."
|
||||
git fetch && git pull
|
||||
|
||||
echo "Resetting files..."
|
||||
git reset
|
||||
|
||||
echo "Adding files..."
|
||||
add
|
||||
|
||||
echo "Removing files..."
|
||||
remove
|
||||
|
||||
echo "Creating commit..."
|
||||
git commit -m "$INPUT_MESSAGE" --author="$INPUT_AUTHOR_NAME <$INPUT_AUTHOR_EMAIL>"
|
||||
|
||||
echo "Tagging commit..."
|
||||
tag
|
||||
|
||||
echo "Pushing commits to repo..."
|
||||
git push --set-upstream origin "$INPUT_REF"
|
||||
|
||||
echo "Pushing tags to repo..."
|
||||
git push --set-upstream origin "$INPUT_REF" --force --tags
|
||||
|
||||
echo "::endgroup::"
|
||||
echo "Task completed."
|
||||
else
|
||||
echo "::endgroup::"
|
||||
echo "Working tree clean. Nothing to commit."
|
||||
fi
|
||||
3
src/inputs.ts
Normal file
3
src/inputs.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
// WARNING: this file is auto-generated by scripts/inputs.ts (npm run inputs), any manual edit will be overwritten.
|
||||
|
||||
export type Input = 'add' | 'author_name' | 'author_email' | 'branch' | 'cwd' | 'message' | 'pull_strategy' | 'remove' | 'signoff' | 'tag'
|
||||
224
src/main.ts
224
src/main.ts
@@ -1,36 +1,216 @@
|
||||
import { info, setFailed, getInput, warning } from '@actions/core'
|
||||
import { join as path } from 'path'
|
||||
import { execFile } from 'child_process'
|
||||
import { info, setFailed, getInput as getInputCore, warning, debug, startGroup, endGroup, error } from '@actions/core'
|
||||
import axios from 'axios'
|
||||
import path from 'path'
|
||||
import simpleGit, { Response } from 'simple-git'
|
||||
|
||||
try {
|
||||
checkInputs()
|
||||
const child = execFile(path(__dirname, 'entrypoint.sh'))
|
||||
child.stdout?.pipe(process.stdout)
|
||||
child.stderr?.pipe(process.stderr)
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
setFailed(err instanceof Error ? err.message : err)
|
||||
}
|
||||
import { Input } from './inputs'
|
||||
|
||||
function checkInputs() {
|
||||
const eventPath = process.env.GITHUB_EVENT_PATH
|
||||
const author = eventPath && require(eventPath)?.head_commit?.author
|
||||
const baseDir = path.join(process.cwd(), getInput('cwd') || '')
|
||||
const git = simpleGit({ baseDir })
|
||||
console.log(`Running in ${baseDir}`);
|
||||
|
||||
(async () => {
|
||||
await checkInputs().catch(setFailed)
|
||||
|
||||
startGroup('Internal logs')
|
||||
info('> Staging files...')
|
||||
|
||||
if (getInput('add')) {
|
||||
info('> Adding files...')
|
||||
await add()
|
||||
} else info('> No files to add.')
|
||||
|
||||
if (getInput('remove')) {
|
||||
info('> Removing files...')
|
||||
await remove()
|
||||
} else info('> No files to remove.')
|
||||
|
||||
info('> Checking for uncommitted changes in the git working tree...')
|
||||
const changedFiles = (await git.diffSummary(['--cached'])).files.length
|
||||
if (changedFiles > 0) {
|
||||
info(`> Found ${changedFiles} changed files.`)
|
||||
|
||||
await git
|
||||
.addConfig('user.email', getInput('author_email'), undefined, log)
|
||||
.addConfig('user.name', getInput('author_name'), undefined, log)
|
||||
debug('> Current git config\n' + JSON.stringify((await git.listConfig()).all, null, 2))
|
||||
|
||||
await git.fetch(['--tags', '--force'], log)
|
||||
|
||||
info('> Switching/creating branch...')
|
||||
await git
|
||||
.checkout(getInput('branch'), undefined, log)
|
||||
.catch(() => git.checkoutLocalBranch(getInput('branch'), log))
|
||||
|
||||
info('> Pulling from remote...')
|
||||
await git
|
||||
.fetch(undefined, log)
|
||||
.pull(undefined, undefined, {
|
||||
[getInput('pull_strategy')]: null
|
||||
}, log)
|
||||
|
||||
info('> Re-staging files...')
|
||||
if (getInput('add')) await add({ ignoreErrors: true })
|
||||
if (getInput('remove')) await remove({ ignoreErrors: true })
|
||||
|
||||
info('> Creating commit...')
|
||||
await git.commit(getInput('message'), undefined, {
|
||||
'--author': `"${getInput('author_name')} <${getInput('author_email')}>"`,
|
||||
...(getInput('signoff') ? {
|
||||
'--signoff': null
|
||||
} : {})
|
||||
}, log)
|
||||
|
||||
if (getInput('tag')) {
|
||||
info('> Tagging commit...')
|
||||
await git.tag(getInput('tag').split(' '), log)
|
||||
} else info('> No tag info provided.')
|
||||
|
||||
info('> Pushing commit to repo...')
|
||||
await git.push('origin', getInput('branch'), { '--set-upstream': null }, log)
|
||||
|
||||
if (getInput('tag')) {
|
||||
info('> Pushing tags to repo...')
|
||||
await git.pushTags('origin', (e, d?) => log(undefined, e || d)).catch(() => {
|
||||
info('> Tag push failed: deleting remote tag and re-pushing...')
|
||||
return git.push(undefined, undefined, {
|
||||
'--delete': null,
|
||||
'origin': null,
|
||||
[getInput('tag').split(' ').filter(w => !w.startsWith('-'))[0]]: null
|
||||
}, log)
|
||||
.pushTags('origin', log)
|
||||
})
|
||||
} else info('> No tags to push.')
|
||||
|
||||
endGroup()
|
||||
info('> Task completed.')
|
||||
} else {
|
||||
endGroup()
|
||||
info('> Working tree clean. Nothing to commit.')
|
||||
}
|
||||
})().catch(e => {
|
||||
endGroup()
|
||||
setFailed(e)
|
||||
})
|
||||
|
||||
async function checkInputs() {
|
||||
function setInput(input: Input, value: string | undefined) {
|
||||
if (value) return process.env[`INPUT_${input.toUpperCase()}`] = value
|
||||
else return delete process.env[`INPUT_${input.toUpperCase()}`]
|
||||
}
|
||||
function setDefault(input: Input, value: string) {
|
||||
if (!getInput(input)) setInput(input, value)
|
||||
return getInput(input)
|
||||
}
|
||||
|
||||
const eventPath = process.env.GITHUB_EVENT_PATH,
|
||||
event = eventPath && require(eventPath),
|
||||
token = process.env.GITHUB_TOKEN,
|
||||
isPR = process.env.GITHUB_EVENT_NAME?.includes('pull_request'),
|
||||
sha = (event?.pull_request?.head?.sha || process.env.GITHUB_SHA) as string,
|
||||
defaultBranch = isPR
|
||||
? event?.pull_request?.head?.ref as string
|
||||
: process.env.GITHUB_REF?.substring(11)
|
||||
|
||||
// #region GITHUB_TOKEN
|
||||
if (!token) warning('The GITHUB_TOKEN env variable is missing: the action may not work as expected.')
|
||||
// #endregion
|
||||
|
||||
// #region add, remove
|
||||
if (!getInput('add') && !getInput('remove'))
|
||||
throw new Error('Both \'add\' and \'remove\' are empty, the action has nothing to do.')
|
||||
// #endregion
|
||||
|
||||
// #region author_name, author_email
|
||||
let author = event?.head_commit?.author
|
||||
if (sha && !author) {
|
||||
info('> Unable to get commit from workflow event: trying with the GitHub API...')
|
||||
|
||||
// https://docs.github.com/en/rest/reference/repos#get-a-commit--code-samples
|
||||
const url = `https://api.github.com/repos/${process.env.GITHUB_REPOSITORY}/commits/${sha}`,
|
||||
headers = token ? {
|
||||
Authorization: `Bearer ${token}`
|
||||
} : undefined,
|
||||
commit = (await axios.get(url, { headers }).catch(err => {
|
||||
startGroup('Request error:')
|
||||
info(`> Request URL: ${url}\b${err}`)
|
||||
endGroup()
|
||||
return undefined
|
||||
}))?.data
|
||||
|
||||
author = commit?.commit?.author
|
||||
}
|
||||
|
||||
if (author) {
|
||||
setDefault('author_name', author.name)
|
||||
setDefault('author_email', author.email)
|
||||
} else {
|
||||
if (!getInput('author_name') || !getInput('author_email')) warning(`Unable to fetch author info: couldn't find ${!eventPath ? 'event path' : !require(eventPath)?.head_commit ? 'commit' : 'commit author'}.`)
|
||||
}
|
||||
|
||||
if (!getInput('author_name') || !getInput('author_email')) {
|
||||
const reason = !eventPath
|
||||
? 'event path'
|
||||
: isPR
|
||||
? sha
|
||||
? 'fetch commit'
|
||||
: 'find commit sha'
|
||||
: !event?.head_commit
|
||||
? 'find commit'
|
||||
: 'find commit author'
|
||||
warning(`Unable to fetch author info: couldn't ${reason}.`)
|
||||
setDefault('author_name', 'Add & Commit Action')
|
||||
setDefault('author_email', 'actions@github.com')
|
||||
}
|
||||
|
||||
setDefault('ref', process.env.GITHUB_REF?.substring(11) || '')
|
||||
info(`> Using '${getInput('author_name')} <${getInput('author_email')}>' as author.`)
|
||||
// #endregion
|
||||
|
||||
info(`Using '${getInput('author_name')} <${getInput('author_email')}>' as author.`)
|
||||
// #region message
|
||||
setDefault('message', `Commit from GitHub Actions (${process.env.GITHUB_WORKFLOW})`)
|
||||
info(`> Using "${getInput('message')}" as commit message.`)
|
||||
// #endregion
|
||||
|
||||
// #region branch
|
||||
const branch = setDefault('branch', defaultBranch || '')
|
||||
if (isPR) info(`> Running for a PR, the action will use '${branch}' as ref.`)
|
||||
// #endregion
|
||||
|
||||
// #region signoff
|
||||
if (getInput('signoff')) try {
|
||||
const parsed = JSON.parse(getInput('signoff'))
|
||||
if (typeof parsed == 'boolean' && !parsed)
|
||||
setInput('signoff', undefined)
|
||||
debug(`Current signoff option: ${getInput('signoff')} (${typeof getInput('signoff')})`)
|
||||
} catch {
|
||||
throw new Error(`"${getInput('signoff')}" is not a valid value for the 'signoff' input: only "true" and "false" are allowed.`)
|
||||
}
|
||||
// #endregion
|
||||
}
|
||||
|
||||
function setDefault(input: string, value: string) {
|
||||
const key = 'INPUT_' + input.toUpperCase()
|
||||
if (!process.env[key]) process.env[key] = value
|
||||
function getInput(name: Input) {
|
||||
return getInputCore(name)
|
||||
}
|
||||
|
||||
function log(err: any | Error, data?: any) {
|
||||
if (data) console.log(data)
|
||||
if (err) error(err)
|
||||
}
|
||||
|
||||
function add({ logWarning = true, ignoreErrors = false } = {}): Promise<void | Response<void>> | void {
|
||||
if (getInput('add'))
|
||||
return git.add(getInput('add').split(' '), (e: any, d?: any) => log(ignoreErrors ? null : e, d)).catch((e: Error) => {
|
||||
if (ignoreErrors) return
|
||||
if (e.message.includes('fatal: pathspec') && e.message.includes('did not match any files'))
|
||||
logWarning && warning('Add command did not match any file.')
|
||||
else throw e
|
||||
})
|
||||
}
|
||||
|
||||
function remove({ logWarning = true, ignoreErrors = false } = {}): Promise<void | Response<void>> | void {
|
||||
if (getInput('remove'))
|
||||
return git.rm(getInput('remove').split(' '), (e: any, d?: any) => log(ignoreErrors ? null : e, d)).catch((e: Error) => {
|
||||
if (ignoreErrors) return
|
||||
if (e.message.includes('fatal: pathspec') && e.message.includes('did not match any files'))
|
||||
logWarning && warning('Remove command did not match any file.')
|
||||
else throw e
|
||||
})
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"**/*.test.ts"
|
||||
"**/*.test.ts",
|
||||
"scripts"
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user