Compare commits
233 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72e246094f | ||
|
|
a9c53e5fc3 | ||
|
|
f9364915ea | ||
|
|
0d80c341c4 | ||
|
|
756d9ea820 | ||
|
|
cb4f06fa66 | ||
|
|
3d8fcf9529 | ||
|
|
664b419dc5 | ||
|
|
7b61ff5331 | ||
|
|
017fbd6dce | ||
|
|
2103e93ecc | ||
|
|
1a5e6d925d | ||
|
|
bfbc660a1b | ||
|
|
7ea52730bc | ||
|
|
0294aa039d | ||
|
|
b9360951d0 | ||
|
|
ab35b67df6 | ||
|
|
03fca92ff8 | ||
|
|
0e1feea77e | ||
|
|
f016b267be | ||
|
|
6fdb34ed01 | ||
|
|
bea30d7628 | ||
|
|
c989bf31e9 | ||
|
|
a790c74dfe | ||
|
|
90c92e18d6 | ||
|
|
b7e58855c4 | ||
|
|
4183cd85fa | ||
|
|
649affade7 | ||
|
|
d4d39927bf | ||
|
|
249b415d1b | ||
|
|
8e3afcf3c9 | ||
|
|
715ee20ac2 | ||
|
|
9b29ba5ec1 | ||
|
|
7d7466136c | ||
|
|
52d096458a | ||
|
|
40463d7b72 | ||
|
|
7392614f5c | ||
|
|
b1323b2f1c | ||
|
|
15c2ba6606 | ||
|
|
8c12ff729a | ||
|
|
5e435d82de | ||
|
|
7d94da29b1 | ||
|
|
f6438de30b | ||
|
|
fbeb5fd3a5 | ||
|
|
49756edd0d | ||
|
|
39badb77ba | ||
|
|
45a4ede867 | ||
|
|
502906541a | ||
|
|
0568295fb2 | ||
|
|
fe1e1da20c | ||
|
|
f6cc47a6d2 | ||
|
|
46020d9ef1 | ||
|
|
4b697d46a2 | ||
|
|
39cfc84aa6 | ||
|
|
e1bc13238c | ||
|
|
d77762158d | ||
|
|
2de1ed6ac4 | ||
|
|
314739c46f | ||
|
|
69da4fbdaf | ||
|
|
42c3cc63a5 | ||
|
|
323b81a282 | ||
|
|
95649ec874 | ||
|
|
75ae3f3b00 | ||
|
|
5a9731b8fa | ||
|
|
b1c040a8e3 | ||
|
|
e7b381e5b1 | ||
|
|
445402b323 | ||
|
|
9711082dae | ||
|
|
ba8cd550ed | ||
|
|
9d257a1a37 | ||
|
|
3649961bcb | ||
|
|
4d9c6e96c4 | ||
|
|
68050c9e64 | ||
|
|
fe4c39abb1 | ||
|
|
6310d67620 | ||
|
|
c735be1920 | ||
|
|
73382ae152 | ||
|
|
4393cf2c11 | ||
|
|
959be48ff3 | ||
|
|
93fa4f5cc2 | ||
|
|
5c82f36c45 | ||
|
|
c5fa67606e | ||
|
|
9614e36026 | ||
|
|
83f497690e | ||
|
|
d5067ccdaf | ||
|
|
45258c519b | ||
|
|
891d0d3f71 | ||
|
|
10f55d517a | ||
|
|
7fc3ba597b | ||
|
|
a32bf6a63e | ||
|
|
043279351f | ||
|
|
bc771e6c1d | ||
|
|
4bc8ca44f5 | ||
|
|
7fe81954dd | ||
|
|
0f29f11a25 | ||
|
|
b1b543f02f | ||
|
|
80cd6897bb | ||
|
|
b97a3a495e | ||
|
|
89725fcd74 | ||
|
|
078c8c02ac | ||
|
|
7c52819e02 | ||
|
|
4a2ad1578f | ||
|
|
275983970a | ||
|
|
c2654d6f08 | ||
|
|
528f445e38 | ||
|
|
8fb41ea727 | ||
|
|
aa55348a4b | ||
|
|
b70fe4ab9e | ||
|
|
173d574290 | ||
|
|
ba6889f70b | ||
|
|
d3dfb259f1 | ||
|
|
8869ee2fb3 | ||
|
|
4377bb38eb | ||
|
|
df4148f15a | ||
|
|
3718b8daa8 | ||
|
|
5511a2ed9d | ||
|
|
2da9ca5709 | ||
|
|
b2e24861f4 | ||
|
|
48c82f4dae | ||
|
|
1294315f5d | ||
|
|
24f3eda418 | ||
|
|
edd941f925 | ||
|
|
ee60873090 | ||
|
|
619b23ff62 | ||
|
|
50a489776c | ||
|
|
eddd081159 | ||
|
|
c4fb7bb8d6 | ||
|
|
2d7c2e89fc | ||
|
|
4c2a2620fa | ||
|
|
61c414aff4 | ||
|
|
587fa5a5d6 | ||
|
|
5451e40a77 | ||
|
|
581b7eb9b6 | ||
|
|
5b22413754 | ||
|
|
703aac3713 | ||
|
|
2591f685a2 | ||
|
|
366eced776 | ||
|
|
b2ad943ed9 | ||
|
|
bf5e32ae7d | ||
|
|
e2885277a1 | ||
|
|
7b6d1027a9 | ||
|
|
b4fa29cd69 | ||
|
|
44ad49f0a5 | ||
|
|
2bdc0a61a0 | ||
|
|
b1dfb478d7 | ||
|
|
6c2b50c246 | ||
|
|
3cbcd603a6 | ||
|
|
ea8b2e7ef9 | ||
|
|
2ef699642a | ||
|
|
88f3f3edfc | ||
|
|
cb134e499a | ||
|
|
4987a27882 | ||
|
|
5aac6ebaf9 | ||
|
|
de103249a8 | ||
|
|
9135e0cf47 | ||
|
|
7ecaaa9364 | ||
|
|
19cc5634e1 | ||
|
|
7242f6d3df | ||
|
|
245f959e32 | ||
|
|
f1c97a931c | ||
|
|
0ca78ab508 | ||
|
|
de0f67d9b6 | ||
|
|
a3adef035a | ||
|
|
e3d054462c | ||
|
|
ee9a9b3bd7 | ||
|
|
c698699df7 | ||
|
|
724766a764 | ||
|
|
eb4e956492 | ||
|
|
5c12301e2f | ||
|
|
0d2694bccc | ||
|
|
7f40311aeb | ||
|
|
c1404d189f | ||
|
|
3276c159ce | ||
|
|
d10f775791 | ||
|
|
bc9a4cf987 | ||
|
|
6d00245624 | ||
|
|
682e840606 | ||
|
|
369f404b6a | ||
|
|
6d400479e9 | ||
|
|
f519dbe2d8 | ||
|
|
7c4f8391e4 | ||
|
|
150689488d | ||
|
|
3edff1c959 | ||
|
|
8a5bf1f2c3 | ||
|
|
b7d8201cc4 | ||
|
|
d09e7e234b | ||
|
|
17dbbf433e | ||
|
|
95a1702b7a | ||
|
|
0d021d8d13 | ||
|
|
0cbeea6850 | ||
|
|
f7574eb56c | ||
|
|
99d8a21c83 | ||
|
|
913fd6894d | ||
|
|
de50d45399 | ||
|
|
e7ec8bd868 | ||
|
|
f1d41def84 | ||
|
|
78d8443c62 | ||
|
|
e49da51881 | ||
|
|
f4b07e6873 | ||
|
|
138434bf13 | ||
|
|
51d91f68e3 | ||
|
|
3e8da6e7cc | ||
|
|
82ec483431 | ||
|
|
701772d352 | ||
|
|
f5554ef7f0 | ||
|
|
17b09154e6 | ||
|
|
3883e0e350 | ||
|
|
d97b8ba941 | ||
|
|
7fe7d23a64 | ||
|
|
7451ee82a1 | ||
|
|
02188ba521 | ||
|
|
2ebdd90daa | ||
|
|
723820f876 | ||
|
|
dca126569c | ||
|
|
e78167ae29 | ||
|
|
d6639f85c1 | ||
|
|
8d2117abc3 | ||
|
|
b3c7c1e078 | ||
|
|
267e04bd5b | ||
|
|
fab2511822 | ||
|
|
57a540778b | ||
|
|
e59e7a1912 | ||
|
|
9c056146c1 | ||
|
|
1146c681e3 | ||
|
|
e3e22e1068 | ||
|
|
544fb5f507 | ||
|
|
60c76066ae | ||
|
|
b09a3f1699 | ||
|
|
299226adbb | ||
|
|
be3ffdfa40 | ||
|
|
ccb8558604 | ||
|
|
03660a0218 | ||
|
|
941a2d657a |
@@ -202,6 +202,155 @@
|
||||
"contributions": [
|
||||
"ideas"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "ocean90",
|
||||
"name": "Dominik Schilling",
|
||||
"avatar_url": "https://avatars2.githubusercontent.com/u/617637?v=4",
|
||||
"profile": "https://dominikschilling.de",
|
||||
"contributions": [
|
||||
"ideas",
|
||||
"doc",
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "rugk",
|
||||
"name": "rugk",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/11966684?v=4",
|
||||
"profile": "https://chaos.social/@rugk",
|
||||
"contributions": [
|
||||
"doc"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "xenoterracide",
|
||||
"name": "Caleb Cushing",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/5517?v=4",
|
||||
"profile": "https://xenoterracide.com",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "ruohola",
|
||||
"name": "Eero Ruohola",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/33625218?v=4",
|
||||
"profile": "https://ruohola.dev",
|
||||
"contributions": [
|
||||
"bug",
|
||||
"ideas"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "vincentchu12",
|
||||
"name": "Vincent Chu",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/23532586?v=4",
|
||||
"profile": "https://github.com/vincentchu12",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "CWSites",
|
||||
"name": "Matt H",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/1242102?v=4",
|
||||
"profile": "https://www.linkedin.com/in/cwsites",
|
||||
"contributions": [
|
||||
"doc",
|
||||
"ideas"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "danielwerg",
|
||||
"name": "danielwerg",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/35052399?v=4",
|
||||
"profile": "https://github.com/danielwerg",
|
||||
"contributions": [
|
||||
"doc"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "koppor",
|
||||
"name": "Oliver Kopp",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/1366654?v=4",
|
||||
"profile": "https://orcid.org/0000-0001-6962-4290",
|
||||
"contributions": [
|
||||
"ideas"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "Glidias",
|
||||
"name": "Glenn Ko",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/190195?v=4",
|
||||
"profile": "https://github.com/Glidias",
|
||||
"contributions": [
|
||||
"ideas"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "drewwells",
|
||||
"name": "Drew Wells",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/239123?v=4",
|
||||
"profile": "http://blog.madewithdrew.com/",
|
||||
"contributions": [
|
||||
"ideas"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "JavierSegoviaCordoba",
|
||||
"name": "Javier Segovia Córdoba",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/7463564?v=4",
|
||||
"profile": "https://kotlin.desarrollador-android.com/",
|
||||
"contributions": [
|
||||
"ideas"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "Darylgolden",
|
||||
"name": "Darylgolden",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/9102529?v=4",
|
||||
"profile": "https://github.com/Darylgolden",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "mcargille",
|
||||
"name": "mcargille",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/20142895?v=4",
|
||||
"profile": "https://github.com/mcargille",
|
||||
"contributions": [
|
||||
"bug",
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "secondmanveran",
|
||||
"name": "secondman",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/97000801?v=4",
|
||||
"profile": "https://github.com/secondmanveran",
|
||||
"contributions": [
|
||||
"doc"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "prince-chrismc",
|
||||
"name": "Chris Mc",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/16867443?v=4",
|
||||
"profile": "https://github.com/prince-chrismc",
|
||||
"contributions": [
|
||||
"doc"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "Namyalg",
|
||||
"name": "Namya LG",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/53875297?v=4",
|
||||
"profile": "https://linkedin.com/in/namyalg",
|
||||
"contributions": [
|
||||
"doc"
|
||||
]
|
||||
}
|
||||
],
|
||||
"contributorsPerLine": 7,
|
||||
|
||||
@@ -4,11 +4,7 @@ module.exports = {
|
||||
es6: true,
|
||||
node: true
|
||||
},
|
||||
extends: [
|
||||
'eslint:recommended',
|
||||
'prettier/@typescript-eslint',
|
||||
'plugin:prettier/recommended'
|
||||
],
|
||||
extends: ['eslint:recommended', 'plugin:prettier/recommended'],
|
||||
globals: {},
|
||||
parser: '@typescript-eslint/parser',
|
||||
parserOptions: {
|
||||
@@ -16,10 +12,12 @@ module.exports = {
|
||||
sourceType: 'module'
|
||||
},
|
||||
plugins: ['@typescript-eslint'],
|
||||
ignorePatterns: ['lib/*'],
|
||||
rules: {
|
||||
'prettier/prettier': 'warn',
|
||||
'no-cond-assign': [2, 'except-parens'],
|
||||
'no-unused-vars': 0,
|
||||
'no-redeclare': 0,
|
||||
'@typescript-eslint/no-unused-vars': 1,
|
||||
'no-empty': [
|
||||
'error',
|
||||
|
||||
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
* text=auto eol=lf
|
||||
lib/* linguist-generated
|
||||
12
.github/FUNDING.yml
vendored
Normal file
12
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: [endbug] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||
2
.github/dependabot.yml
vendored
2
.github/dependabot.yml
vendored
@@ -13,4 +13,4 @@ updates:
|
||||
prefix: 'chore'
|
||||
include: 'scope'
|
||||
labels:
|
||||
- 'type: dependencies'
|
||||
- 'type: chore'
|
||||
|
||||
62
.github/labels.yml
vendored
62
.github/labels.yml
vendored
@@ -1,4 +1,3 @@
|
||||
# General purpose
|
||||
- name: 'good first issue'
|
||||
color: '5319e7'
|
||||
description: 'Good for newcomers'
|
||||
@@ -11,70 +10,65 @@
|
||||
|
||||
- name: 'status: pending'
|
||||
color: c5def5
|
||||
description: 'More info is needed before deciding what to do.'
|
||||
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.'
|
||||
description: 'Should not be labeled as stale'
|
||||
aliases: []
|
||||
|
||||
- name: 'status: stale'
|
||||
color: fbca04
|
||||
description: 'Inactive issues and PRs.'
|
||||
description: 'Inactive issues and PRs'
|
||||
aliases: ['stale']
|
||||
|
||||
- name: 'status: wontfix'
|
||||
color: ffffff
|
||||
description: 'This will not be worked on.'
|
||||
color: cfd3d7
|
||||
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.'
|
||||
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: chore'
|
||||
color: C5DEF5
|
||||
description: 'Code changes that neither fix bugs nor add features (refactoring, dependency chnages, ...)'
|
||||
aliases: ['dependencies', 'type: dependencies', 'automation', 'type: automation']
|
||||
|
||||
- name: 'type: docs'
|
||||
color: C5DEF5
|
||||
description: "Documentation changes"
|
||||
aliases: ['documentation', 'maintenance', 'type: maintenance']
|
||||
|
||||
- name: 'type: duplicate'
|
||||
color: cfd3d7
|
||||
description: 'This issue or pull request already exists.'
|
||||
description: 'This issue or pull request already exists'
|
||||
aliases: ['duplicate']
|
||||
|
||||
- name: 'type: enhancement'
|
||||
color: a2eeef
|
||||
description: 'New feature or request.'
|
||||
aliases: ['enhancement']
|
||||
- name: 'type: feature'
|
||||
color: 0E8A16
|
||||
description: 'New feature or feature request'
|
||||
aliases: ['enhancement', 'type: enhancement']
|
||||
|
||||
- name: 'type: fix'
|
||||
color: 1D76DB
|
||||
description: 'Updates to existing functionalities'
|
||||
aliases: ['fix']
|
||||
|
||||
- name: 'type: invalid'
|
||||
color: e4e669
|
||||
description: "This doesn't seem right."
|
||||
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.'
|
||||
description: 'Reports that happen not be our fault'
|
||||
aliases: ['not a bug']
|
||||
|
||||
- name: 'type: question'
|
||||
color: d876e3
|
||||
description: 'Further information is requested.'
|
||||
description: 'Further information is requested'
|
||||
aliases: ['question']
|
||||
|
||||
- name: 'type: security'
|
||||
color: 'ee0701'
|
||||
description: 'Pull requests that address a security vulnerability.'
|
||||
aliases: ['security']
|
||||
|
||||
19
.github/stale.yml
vendored
Normal file
19
.github/stale.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
# Number of days of inactivity before an issue becomes stale
|
||||
daysUntilStale: 20
|
||||
# Number of days of inactivity before a stale issue is closed
|
||||
daysUntilClose: 5
|
||||
# Issues with these labels will never be considered stale
|
||||
exemptLabels:
|
||||
- pinned
|
||||
- security
|
||||
- 'status: pinned'
|
||||
- 'type: security'
|
||||
# Label to use when marking an issue as stale
|
||||
staleLabel: 'status: stale'
|
||||
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||
markComment: >
|
||||
This issue has been automatically marked as stale because it has not had
|
||||
recent activity. It will be closed if no further activity occurs. Thank you
|
||||
for your contributions.
|
||||
# Comment to post when closing a stale issue. Set to `false` to disable
|
||||
closeComment: false
|
||||
70
.github/workflows/codeql-analysis.yml
vendored
Normal file
70
.github/workflows/codeql-analysis.yml
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
#
|
||||
# ******** NOTE ********
|
||||
# We have attempted to detect the languages in your repository. Please check
|
||||
# the `language` matrix defined below to confirm you have the correct set of
|
||||
# supported CodeQL languages.
|
||||
#
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ main ]
|
||||
schedule:
|
||||
- cron: '40 12 * * 2'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'javascript' ]
|
||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
||||
# Learn more about CodeQL language support at https://git.io/codeql-language-support
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
#- run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
||||
21
.github/workflows/stale.yml
vendored
21
.github/workflows/stale.yml
vendored
@@ -1,21 +0,0 @@
|
||||
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
|
||||
1
.husky/.gitignore
vendored
Normal file
1
.husky/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
_
|
||||
5
.husky/pre-commit
Normal file
5
.husky/pre-commit
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
npm run build
|
||||
git add lib
|
||||
114
CHANGELOG.md
114
CHANGELOG.md
@@ -7,6 +7,106 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [8.0.2] - 2022-02-07
|
||||
|
||||
### Fixed:
|
||||
|
||||
- The `commit` input is now properly listed in the README. (#360)
|
||||
|
||||
## [8.0.1] - 2022-01-23
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Fixed a bug that prevented the `--allow-empty` flag from being used for the `commit` input. (#352)
|
||||
- Fixed README and CHANGELOG docs for the `pull` input, that were still showing the option to use `NO-PULL` to prevent pulling (while now it's the default behavior). (#354)
|
||||
- Added a paragraph to the FAQs section of the README, that explains how to work with PRs in v8. (#351)
|
||||
|
||||
## [8.0.0] - 2022-01-20
|
||||
|
||||
### Fixed:
|
||||
|
||||
- **[BREAKING]** The action will now work with whatever ref has been checked out, without pulling or switching branches by default. You can still pull using the `pull` input and create a new branch with the newly-added `new_branch` input. For more info, check commit [`6fdb34e`](https://github.com/EndBug/add-and-commit/commit/6fdb34ed01d242c909eeb7e31bf1c4d37db43a54).
|
||||
|
||||
### Removed:
|
||||
|
||||
- **[BREAKING]** The `signoff` input has been removed, use `commit` instead. (#331)
|
||||
- **[BREAKING]** The `pull_strategy` input has been removed, use `pull` instead.
|
||||
- **[BREAKING]** The `branch` and `branch_mode` inputs have been removed, check commit [`6fdb34e`](https://github.com/EndBug/add-and-commit/commit/6fdb34ed01d242c909eeb7e31bf1c4d37db43a54) for more info.
|
||||
- **[BREAKING]** The `pull` input doesn't support `NO-PULL` anymore: if you don't want the action to pull, simply remove the input, as it's the default behavior now.
|
||||
|
||||
### Added:
|
||||
|
||||
- Added the `commit` input, that allows you to change the arguments for the `git commit` command. (#331)
|
||||
- Added the `new_branch` input. ([`6fdb34e`](https://github.com/EndBug/add-and-commit/commit/6fdb34ed01d242c909eeb7e31bf1c4d37db43a54))
|
||||
- Added the `commit_long_sha` output. (#349)
|
||||
|
||||
## [7.5.0] - 2021-12-03
|
||||
|
||||
### Added:
|
||||
|
||||
- Support remote branch creation: use the `branch_mode` input to make the action create a new branch when there's no branch with the given name on the remote (#329)
|
||||
|
||||
## [7.4.0] - 2021-09-30
|
||||
|
||||
### Added:
|
||||
|
||||
- Added `pull` input: you can use it to change the arguments of the `git pull` command (#294)
|
||||
|
||||
### Changed:
|
||||
|
||||
- Deprecated `pull_strategy`: use `pull` instead (#294)
|
||||
|
||||
## [7.3.0] - 2021-09-06
|
||||
|
||||
### Added:
|
||||
|
||||
- Added custom committer support via the `committer_name` and `committer_email` inputs (#264)
|
||||
- Added `commit_sha` output (#275)
|
||||
- Added `pathspec_error_handling` input (#280)
|
||||
|
||||
## [7.2.1] - 2021-05-11
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Fixed an issue with missing outputs (#189)
|
||||
|
||||
## [7.2.0] - 2021-04-22
|
||||
|
||||
### Added:
|
||||
|
||||
- `default_author`: this input allows you to control how the action fills missing author name or email (issue #167)
|
||||
- `github_token` input introduced to get token to use in API calls
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Git args are now parsed with [`string-argv`](https://npm.im/string-argv), the format has to comply with what the package can parse (issue #179)
|
||||
|
||||
## [7.1.2] - 2021-04-16
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Git args parsing now correctly handles quotes, that can be used for multi-word arguments (issue #166)
|
||||
|
||||
## [7.1.1] - 2021-04-04
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Git args parsing has been improved, and now handles spaces correctly (issue #154)
|
||||
|
||||
## [7.1.0] - 2021-03-03
|
||||
|
||||
### Added:
|
||||
|
||||
- `pull_strategy`: you can use 'NO-PULL' to prevent the action from pulling from the remote at all.
|
||||
|
||||
## [7.0.0] - 2021-01-16
|
||||
|
||||
### Changed:
|
||||
|
||||
- **[BREAKING]** The token input has been removed: author info will be filled using the GitHub Actor, instead of fetching info from the GitHub API.
|
||||
The commits will be authored using the GitHub no-reply email associated with the account: username@users.noreply.github.com
|
||||
- **[BREAKING]** Because of the change above, the author will now be the user that triggered the action run, and not the author of the last commit: while the two are often the same person, there are instances where they might differ (e.g. when a workflow run is triggered manually).
|
||||
|
||||
## [6.2.0] - 2020-12-23
|
||||
|
||||
### Added:
|
||||
@@ -205,7 +305,7 @@ First release
|
||||
|
||||
#
|
||||
|
||||
[unreleased]: https://github.com/EndBug/add-and-commit/compare/v6.2.0...HEAD
|
||||
[unreleased]: https://github.com/EndBug/add-and-commit/compare/v8.0.2...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
|
||||
@@ -234,3 +334,15 @@ First release
|
||||
[6.0.0]: https://github.com/EndBug/add-and-commit/compare/v5.3.0...v6.0.0
|
||||
[6.1.0]: https://github.com/EndBug/add-and-commit/compare/v6.0.0...v6.1.0
|
||||
[6.2.0]: https://github.com/EndBug/add-and-commit/compare/v6.1.0...v6.2.0
|
||||
[7.0.0]: https://github.com/EndBug/add-and-commit/compare/v6.2.0...v7.0.0
|
||||
[7.1.0]: https://github.com/EndBug/add-and-commit/compare/v7.0.0...v7.1.0
|
||||
[7.1.1]: https://github.com/EndBug/add-and-commit/compare/v7.1.0...v7.1.1
|
||||
[7.1.2]: https://github.com/EndBug/add-and-commit/compare/v7.1.1...v7.1.2
|
||||
[7.2.0]: https://github.com/EndBug/add-and-commit/compare/v7.1.2...v7.2.0
|
||||
[7.2.1]: https://github.com/EndBug/add-and-commit/compare/v7.2.0...v7.2.1
|
||||
[7.3.0]: https://github.com/EndBug/add-and-commit/compare/v7.2.1...v7.3.0
|
||||
[7.4.0]: https://github.com/EndBug/add-and-commit/compare/v7.3.0...v7.4.0
|
||||
[7.5.0]: https://github.com/EndBug/add-and-commit/compare/v7.4.0...v7.5.0
|
||||
[8.0.0]: https://github.com/EndBug/add-and-commit/compare/v7.5.0...v8.0.0
|
||||
[8.0.1]: https://github.com/EndBug/add-and-commit/compare/v8.0.0...v8.0.1
|
||||
[8.0.2]: https://github.com/EndBug/add-and-commit/compare/v8.0.1...v8.0.2
|
||||
|
||||
284
README.md
284
README.md
@@ -1,47 +1,78 @@
|
||||
# Add & Commit
|
||||
|
||||
[](https://github.com/search?o=desc&q=EndBug+add-and-commit+path%3A.github%2Fworkflows+language%3AYAML&s=&type=Code)
|
||||
[](https://github.com/search?o=desc&q=EndBug+add-and-commit+path%3A.github%2Fworkflows+language%3AYAML&s=&type=Code)
|
||||
[](#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....
|
||||
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...
|
||||
|
||||
This is **heavily** inspired by [git-auto-commit-action](https://github.com/stefanzweifel/git-auto-commit-action) (by [Stefan Zweifel](https://github.com/stefanzweifel)): that action automatically detects changed files and commits them. While this is useful for most situations, this doesn't commit untracked files and can sometimes commit unintended changes (such as `package-lock.json` or similar, that may have happened during previous steps).
|
||||
This action lets you choose the path that you want to use when adding & committing changes so that it works as you would normally do using `git` on your machine.
|
||||
## Table of contents
|
||||
|
||||
## Usage
|
||||
- [Inputs](#inputs)
|
||||
- [Outputs](#outputs)
|
||||
- [FAQs](#faqs)
|
||||
- [Examples](#examples)
|
||||
- [Contributors](#contributors-)
|
||||
|
||||
## Inputs
|
||||
|
||||
Add a step like this to your workflow:
|
||||
|
||||
```yaml
|
||||
- uses: EndBug/add-and-commit@v6 # You can change this to use a specific version
|
||||
- uses: EndBug/add-and-commit@v8 # 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: '.'
|
||||
add: 'src'
|
||||
|
||||
# The name of the user that will be displayed as the author of the commit
|
||||
# Default: author of the commit that triggered the run
|
||||
author_name: Your Name
|
||||
# The name of the user that will be displayed as the author of the commit.
|
||||
# Default: depends on the default_author input
|
||||
author_name: Author Name
|
||||
|
||||
# The email of the user that will be displayed as the author of the commit
|
||||
# Default: author of the commit that triggered the run
|
||||
# The email of the user that will be displayed as the author of the commit.
|
||||
# Default: depends on the default_author input
|
||||
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
|
||||
# Additional arguments for the git commit command. The --message argument is already set by the message input.
|
||||
# Default: ''
|
||||
commit: --signoff
|
||||
|
||||
# The local path to the directory where your repository is located. You should use actions/checkout first to set it up
|
||||
# The name of the custom committer you want to use, if different from the author of the commit.
|
||||
# Default: the name of the author (set with either author_name or default_author)
|
||||
committer_name: Committer Name
|
||||
|
||||
# The email of the custom committer you want to use, if different from the author of the commit.
|
||||
# Default: the email of the author (set with either author_email or default_author)
|
||||
committer_email: mail@example.com
|
||||
|
||||
# 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'
|
||||
|
||||
# The message for the commit
|
||||
# Determines the way the action fills missing author name and email. Three options are available:
|
||||
# - github_actor -> UserName <UserName@users.noreply.github.com>
|
||||
# - user_info -> Your Display Name <your-actual@email.com>
|
||||
# - github_actions -> github-actions <email associated with the github logo>
|
||||
# Default: github_actor
|
||||
default_author: github_actor
|
||||
|
||||
# The message for the commit.
|
||||
# Default: 'Commit from GitHub Actions (name of the workflow)'
|
||||
message: 'Your commit message'
|
||||
|
||||
# The flag used on the pull strategy
|
||||
# Default: '--no-rebase'
|
||||
pull_strategy: '--no-rebase or --no-ff or --rebase'
|
||||
# If this input is set, the action will push the commit to a new branch with this name.
|
||||
# Default: ''
|
||||
new_branch: custom-new-branch
|
||||
|
||||
# The way the action should handle pathspec errors from the add and remove commands. Three options are available:
|
||||
# - ignore -> errors will be logged but the step won't fail
|
||||
# - exitImmediately -> the action will stop right away, and the step will fail
|
||||
# - exitAtEnd -> the action will go on, every pathspec error will be logged at the end, the step will fail.
|
||||
# Default: ignore
|
||||
pathspec_error_handling: ignore
|
||||
|
||||
# Arguments for the git pull command. By default, the action does not pull.
|
||||
# Default: ''
|
||||
pull: '--rebase --autostash ...'
|
||||
|
||||
# Whether to push the commit and, if any, its tags to the repo. It can also be used to set the git push arguments (see the paragraph below for more info)
|
||||
# Default: true
|
||||
@@ -51,34 +82,31 @@ Add a step like this to your workflow:
|
||||
# Default: ''
|
||||
remove: './dir/old_file.js'
|
||||
|
||||
# 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 --force'
|
||||
|
||||
# Token to use for pushing the commit. The default value won't trigger any workflows, you need to use a Personal Access Token for that.
|
||||
# Default: secrets.GITHUB_TOKEN
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
### Adding files:
|
||||
### Git arguments
|
||||
|
||||
Multiple options let you provide the git arguments that you want the action to use. It's important to note that these arguments **are not actually used with a CLI command**, but they are parsed by a package called [`string-argv`](https://npm.im/string-argv), and then used with [`simple-git`](https://npm.im/simple-git).
|
||||
What does this mean for you? It means that string that contain a lot of nested quotes may be parsed incorrectly, and that specific ways of declaring arguments may not be supported by this libraries. If you're having issues with your argument strings you can check whether they're being parsed correctly either by [enabling debug logging](https://docs.github.com/en/actions/managing-workflow-runs/enabling-debug-logging) for your workflow runs or by testing it directly with `string-argv` ([RunKit demo](https://npm.runkit.com/string-argv)): if each argument and option is aprsed correctly you'll see an array where every string is an option or value.
|
||||
|
||||
### 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 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.
|
||||
The script will not stop if one of the git commands doesn't match any file. E.g.: if your command shows a "fatal: pathspec 'yourFile' did not match any files" error the action will go on.
|
||||
You can also use JSON or YAML arrays (e.g. `'["first", "second"]'`, `"['first', 'second']"`) to make the action run multiple `git add` commands: the action will log how your input has been parsed. Please mind that your input still needs to be a string because of how GitHub Actions works with inputs: just write your array inside the string, the action will parse it later.
|
||||
|
||||
### Deleting files:
|
||||
### 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. 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.
|
||||
The script will not stop if one of the git commands doesn't match any file. E.g.: if your command shows a "fatal: pathspec 'yourFile' did not match any files" error the action will go on.
|
||||
You can also use JSON or YAML arrays (e.g. `'["first", "second"]'`, `"['first', 'second']"`) to make the action run multiple `git rm` commands: the action will log how your input has been parsed. Please mind that your input still needs to be a string because of how GitHub Actions works with inputs: just write your array inside the string, the action will parse it later.
|
||||
|
||||
### Pushing:
|
||||
### Pushing
|
||||
|
||||
By default the action runs the following command: `git push origin ${branch input} --set-upstream`. You can use the `push` input to modify this behavior, here's what you can set it to:
|
||||
By default the action runs the following command: `git push origin ${new_branch input} --set-upstream`. You can use the `push` input to modify this behavior, here's what you can set it to:
|
||||
|
||||
- `true`: this is the default value, it will behave as usual.
|
||||
- `false`: this prevents the action from pushing at all, no `git push` command is run.
|
||||
@@ -87,21 +115,127 @@ By default the action runs the following command: `git push origin ${branch inpu
|
||||
|
||||
One way to use this is if you want to force push to a branch of your repo: you'll need to set the `push` input to, for example, `origin yourBranch --force`.
|
||||
|
||||
### Tagging:
|
||||
### Creating a new branch
|
||||
|
||||
If you want the action to commit in a new branch, you can use the `new_branch` input.
|
||||
|
||||
Please note that if the branch exists, the action will still try push to it, but it's possible that the push will be rejected by the remote as non-straightforward.
|
||||
|
||||
If that's the case, you need to make sure that the branch you want to commit to is already checked out before you run the action.
|
||||
If you're **really** sure that you want to commit to that branch, you can also force-push by setting the `push` input to something like `origin yourBranchName --set-upstream --force`.
|
||||
|
||||
If you want to commit files "across different branches", here are two ways to do it:
|
||||
|
||||
1. You can check them out in two different directories, generate your files, move them to your destination and then run `add-and-commit` in the destination directory using the `cwd` input.
|
||||
2. You can manually commit those files with `git` commands as you would on your machine. There are several ways to do this depending on the scenario. One of them if to stash your changes, checkout the destination branch, and popping the stash. You can then use the `add-and-commit` action as usual. Please note that this is just an example and may not work for you, since your use case may be different.
|
||||
|
||||
### Tagging
|
||||
|
||||
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).
|
||||
|
||||
### Outputs:
|
||||
## Outputs
|
||||
|
||||
The action provides these outputs:
|
||||
|
||||
- `committed`: whether the action has created a commit (`'true'` or `'false'`)
|
||||
- `pushed`: whether the action has pushed to teh remote(`'true'` or `'false'`)
|
||||
- `commit_long_sha`: the full SHA of the commit that has just been created
|
||||
- `commit_sha`: the short 7-character SHA of the commit that has just been created
|
||||
- `pushed`: whether the action has pushed to the remote (`'true'` or `'false'`)
|
||||
- `tagged`: whether the action has created a tag (`'true'` or `'false'`)
|
||||
|
||||
For more info on how to use outputs, see ["Context and expression syntax"](https://docs.github.com/en/free-pro-team@latest/actions/reference/context-and-expression-syntax-for-github-actions).
|
||||
|
||||
### Examples:
|
||||
## FAQs
|
||||
|
||||
### Working with PRs
|
||||
|
||||
By default, when you use `actions/checkout` on a PR, it will checkout the head commit in a detached head state.
|
||||
If you want to make some changes, you have to checkout the branch the PR is coming from in the head repo.
|
||||
You can set it up like this:
|
||||
|
||||
```yaml
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
ref: ${{ github.event.pull_request.head.ref }}
|
||||
```
|
||||
|
||||
You can find the full docs for payloads of `pull_request` events [here](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#webhook-payload-example-32).
|
||||
|
||||
If you're planning on running this only on "internal" PRs (where head and base are in the same repo) then you can omit the `repository` input.
|
||||
If you're planning to use this with PRs coming from other forks, please keep in mind that you might not have write access to those repos.
|
||||
You can try setting up the repo with your PAT, as explained in the ["About tokens" paragraph](#about-tokens) of this section.
|
||||
|
||||
Keep in mind that this "custom checkout" is meant only for PRs: if your workflow runs on multiple events (like `push` or `workflow_dispatch`), you could try having this step run only for `pull_request` events, while other ones will trigger the usual checkout.
|
||||
If you wish to do so, you can use the `step.if` property, [here](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsif)'s the docs.
|
||||
|
||||
### About tokens
|
||||
|
||||
When pushing, the action uses the token that the local git repository has been configured with: that means that if you want to change it you'll need to do it in the steps that run before this action. For example: if you set up your repo with [`actions/checkout`](https://github.com/actions/checkout/) then you have to add the token there.
|
||||
Changing the token with which the repo is configured can be useful if you want to run CI checks on the commit pushed by this action; anyway, it has to be set up outside of this action.
|
||||
|
||||
The action automatically gets the GitHub token from a `github_token` input: this input should not be modified by the user, since it doesn't affect the commits as it's only used to access the GitHub API to get user info, in case they selected that option for the commit author.
|
||||
|
||||
### The commit from the action is not triggering CI!
|
||||
|
||||
That's because you're checking out the repo using the built-in [`GITHUB_TOKEN` secret](https://docs.github.com/en/actions/security-guides/automatic-token-authentication): GitHub sees that the push event has been triggered by a commit generated by CI, and doesn't run any further checks to avoid unintentional check loops.
|
||||
|
||||
**If you're sure** that you want the commits generated during CI to trigger other workflow runs, you can checkout the repo using a [Personal Access Token (PAT)](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token): this will make the resulting commit the same as if you made it yourself.
|
||||
If you're using `actions/checkout`, check out their [docs](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) to see how to set your repo token.
|
||||
|
||||
### About `actions/checkout`
|
||||
|
||||
The token you use when setting up the repo with this action will determine what token `add-and-commit` will use.
|
||||
Some users reported that they were getting an error:
|
||||
|
||||
```
|
||||
> fatal: could not read Username for 'https://github.com': No such device or address
|
||||
```
|
||||
|
||||
If you're getting this error and you're using `actions/checkout@v1`, try upgrading to `actions/checkout@v2`. If you're still having problems after upgrading, feel free to open an issue. Issue ref: [#146](https://github.com/EndBug/add-and-commit/issues/146)
|
||||
|
||||
## Examples
|
||||
|
||||
### Different author/committer configurations
|
||||
|
||||
If you don't want to use your GitHub username for the CI commits, you can use the `default_author` option to make it appear as if it was made by "github-actions"
|
||||
|
||||
<img src="https://user-images.githubusercontent.com/26386270/115738624-80b51780-a38d-11eb-9bbe-77461654274c.png" height=40/>
|
||||
|
||||
```yaml
|
||||
on: push
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: EndBug/add-and-commit@v8
|
||||
with:
|
||||
default_author: github_actions
|
||||
```
|
||||
|
||||
You can also use the `committer_name` and `committer_email` inputs to make it appear as if GitHub Actions is the committer, here are a couple of example steps:
|
||||
|
||||
<img src="https://user-images.githubusercontent.com/26386270/130594168-1d910710-e2d0-4b06-9324-cbe5dde59154.png" height=70/>
|
||||
|
||||
```yaml
|
||||
- uses: EndBug/add-and-commit@v8
|
||||
with:
|
||||
message: Show GitHub Actions logo
|
||||
committer_name: GitHub Actions
|
||||
committer_email: actions@github.com
|
||||
```
|
||||
|
||||
<img src="https://user-images.githubusercontent.com/26386270/130594443-b881fae7-3064-4020-a4cc-6db37ef0df65.png" height=70/>
|
||||
|
||||
```yaml
|
||||
- uses: EndBug/add-and-commit@v8
|
||||
with:
|
||||
message: Show GitHub logo
|
||||
committer_name: GitHub Actions
|
||||
committer_email: 41898282+github-actions[bot]@users.noreply.github.com
|
||||
```
|
||||
|
||||
### Automated linting
|
||||
|
||||
Do you want to lint your JavaScript files, located in the `src` folder, with ESLint, so that fixable changes are done without your intervention? You can use a workflow like this:
|
||||
|
||||
@@ -129,7 +263,7 @@ jobs:
|
||||
run: eslint "src/**" --fix
|
||||
|
||||
- name: Commit changes
|
||||
uses: EndBug/add-and-commit@v6
|
||||
uses: EndBug/add-and-commit@v8
|
||||
with:
|
||||
author_name: Your Name
|
||||
author_email: mail@example.com
|
||||
@@ -137,6 +271,8 @@ jobs:
|
||||
add: '*.js'
|
||||
```
|
||||
|
||||
### Running the action in a different directory
|
||||
|
||||
If you need to run the action on a repository that is not located in [`$GITHUB_WORKSPACE`](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/using-environment-variables#default-environment-variables), you can use the `cwd` option: the action uses a `cd` normal command, so the path should follow bash standards.
|
||||
|
||||
```yaml
|
||||
@@ -158,7 +294,7 @@ 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@v6
|
||||
- uses: EndBug/add-and-commit@v8
|
||||
with:
|
||||
message: 'Add the very useful text file'
|
||||
add: '*.txt --force'
|
||||
@@ -174,41 +310,67 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
||||
<!-- 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>
|
||||
<td align="center"><a href="https://github.com/EndBug"><img src="https://avatars1.githubusercontent.com/u/26386270?v=4?s=100" 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?s=100" 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?s=100" 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?s=100" 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?s=100" 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?s=100" 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?s=100" 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>
|
||||
<td align="center"><a href="http://robinwijnant.me"><img src="https://avatars3.githubusercontent.com/u/33033209?v=4?s=100" 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?s=100" 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?s=100" 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?s=100" 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?s=100" 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?s=100" 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?s=100" 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> <a href="https://github.com/EndBug/add-and-commit/commits?author=Cyberbeni" title="Code">💻</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>
|
||||
<td align="center"><a href="https://github.com/Chocrates"><img src="https://avatars1.githubusercontent.com/u/1758164?v=4" width="100px;" alt=""/><br /><sub><b>Chris McIntosh</b></sub></a><br /><a href="https://github.com/EndBug/add-and-commit/issues?q=author%3AChocrates" title="Bug reports">🐛</a></td>
|
||||
<td align="center"><a href="https://github.com/kbsali"><img src="https://avatars0.githubusercontent.com/u/53676?v=4" width="100px;" alt=""/><br /><sub><b>Kevin Saliou</b></sub></a><br /><a href="#ideas-kbsali" title="Ideas, Planning, & Feedback">🤔</a></td>
|
||||
<td align="center"><a href="https://github.com/ewjoachim"><img src="https://avatars0.githubusercontent.com/u/1457576?v=4" width="100px;" alt=""/><br /><sub><b>Joachim Jablon</b></sub></a><br /><a href="#ideas-ewjoachim" title="Ideas, Planning, & Feedback">🤔</a></td>
|
||||
<td align="center"><a href="https://github.com/trallnag"><img src="https://avatars3.githubusercontent.com/u/24834206?v=4" width="100px;" alt=""/><br /><sub><b>Tim Schwenke</b></sub></a><br /><a href="#ideas-trallnag" title="Ideas, Planning, & Feedback">🤔</a></td>
|
||||
<td align="center"><a href="https://www.somethingcatchy.net"><img src="https://avatars1.githubusercontent.com/u/12880806?v=4" width="100px;" alt=""/><br /><sub><b>Possible Triangle</b></sub></a><br /><a href="#ideas-PssbleTrngle" title="Ideas, Planning, & Feedback">🤔</a></td>
|
||||
<td align="center"><a href="https://github.com/Cyberbeni"><img src="https://avatars1.githubusercontent.com/u/8356175?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Benedek Kozma</b></sub></a><br /><a href="#ideas-Cyberbeni" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/EndBug/add-and-commit/commits?author=Cyberbeni" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/coffeegoddd"><img src="https://avatars3.githubusercontent.com/u/43383835?v=4?s=100" 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>
|
||||
<td align="center"><a href="https://github.com/Chocrates"><img src="https://avatars1.githubusercontent.com/u/1758164?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Chris McIntosh</b></sub></a><br /><a href="https://github.com/EndBug/add-and-commit/issues?q=author%3AChocrates" title="Bug reports">🐛</a></td>
|
||||
<td align="center"><a href="https://github.com/kbsali"><img src="https://avatars0.githubusercontent.com/u/53676?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kevin Saliou</b></sub></a><br /><a href="#ideas-kbsali" title="Ideas, Planning, & Feedback">🤔</a></td>
|
||||
<td align="center"><a href="https://github.com/ewjoachim"><img src="https://avatars0.githubusercontent.com/u/1457576?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Joachim Jablon</b></sub></a><br /><a href="#ideas-ewjoachim" title="Ideas, Planning, & Feedback">🤔</a></td>
|
||||
<td align="center"><a href="https://github.com/trallnag"><img src="https://avatars3.githubusercontent.com/u/24834206?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tim Schwenke</b></sub></a><br /><a href="#ideas-trallnag" title="Ideas, Planning, & Feedback">🤔</a></td>
|
||||
<td align="center"><a href="https://www.somethingcatchy.net"><img src="https://avatars1.githubusercontent.com/u/12880806?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Possible Triangle</b></sub></a><br /><a href="#ideas-PssbleTrngle" title="Ideas, Planning, & Feedback">🤔</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><a href="https://dominikschilling.de"><img src="https://avatars2.githubusercontent.com/u/617637?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Dominik Schilling</b></sub></a><br /><a href="#ideas-ocean90" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/EndBug/add-and-commit/commits?author=ocean90" title="Documentation">📖</a> <a href="https://github.com/EndBug/add-and-commit/commits?author=ocean90" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://chaos.social/@rugk"><img src="https://avatars.githubusercontent.com/u/11966684?v=4?s=100" width="100px;" alt=""/><br /><sub><b>rugk</b></sub></a><br /><a href="https://github.com/EndBug/add-and-commit/commits?author=rugk" title="Documentation">📖</a></td>
|
||||
<td align="center"><a href="https://xenoterracide.com"><img src="https://avatars.githubusercontent.com/u/5517?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Caleb Cushing</b></sub></a><br /><a href="https://github.com/EndBug/add-and-commit/issues?q=author%3Axenoterracide" title="Bug reports">🐛</a></td>
|
||||
<td align="center"><a href="https://ruohola.dev"><img src="https://avatars.githubusercontent.com/u/33625218?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Eero Ruohola</b></sub></a><br /><a href="https://github.com/EndBug/add-and-commit/issues?q=author%3Aruohola" title="Bug reports">🐛</a> <a href="#ideas-ruohola" title="Ideas, Planning, & Feedback">🤔</a></td>
|
||||
<td align="center"><a href="https://github.com/vincentchu12"><img src="https://avatars.githubusercontent.com/u/23532586?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vincent Chu</b></sub></a><br /><a href="https://github.com/EndBug/add-and-commit/issues?q=author%3Avincentchu12" title="Bug reports">🐛</a></td>
|
||||
<td align="center"><a href="https://www.linkedin.com/in/cwsites"><img src="https://avatars.githubusercontent.com/u/1242102?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Matt H</b></sub></a><br /><a href="https://github.com/EndBug/add-and-commit/commits?author=CWSites" title="Documentation">📖</a> <a href="#ideas-CWSites" title="Ideas, Planning, & Feedback">🤔</a></td>
|
||||
<td align="center"><a href="https://github.com/danielwerg"><img src="https://avatars.githubusercontent.com/u/35052399?v=4?s=100" width="100px;" alt=""/><br /><sub><b>danielwerg</b></sub></a><br /><a href="https://github.com/EndBug/add-and-commit/commits?author=danielwerg" title="Documentation">📖</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><a href="https://orcid.org/0000-0001-6962-4290"><img src="https://avatars.githubusercontent.com/u/1366654?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Oliver Kopp</b></sub></a><br /><a href="#ideas-koppor" title="Ideas, Planning, & Feedback">🤔</a></td>
|
||||
<td align="center"><a href="https://github.com/Glidias"><img src="https://avatars.githubusercontent.com/u/190195?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Glenn Ko</b></sub></a><br /><a href="#ideas-Glidias" title="Ideas, Planning, & Feedback">🤔</a></td>
|
||||
<td align="center"><a href="http://blog.madewithdrew.com/"><img src="https://avatars.githubusercontent.com/u/239123?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Drew Wells</b></sub></a><br /><a href="#ideas-drewwells" title="Ideas, Planning, & Feedback">🤔</a></td>
|
||||
<td align="center"><a href="https://kotlin.desarrollador-android.com/"><img src="https://avatars.githubusercontent.com/u/7463564?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Javier Segovia Córdoba</b></sub></a><br /><a href="#ideas-JavierSegoviaCordoba" title="Ideas, Planning, & Feedback">🤔</a></td>
|
||||
<td align="center"><a href="https://github.com/Darylgolden"><img src="https://avatars.githubusercontent.com/u/9102529?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Darylgolden</b></sub></a><br /><a href="https://github.com/EndBug/add-and-commit/issues?q=author%3ADarylgolden" title="Bug reports">🐛</a></td>
|
||||
<td align="center"><a href="https://github.com/mcargille"><img src="https://avatars.githubusercontent.com/u/20142895?v=4?s=100" width="100px;" alt=""/><br /><sub><b>mcargille</b></sub></a><br /><a href="https://github.com/EndBug/add-and-commit/issues?q=author%3Amcargille" title="Bug reports">🐛</a> <a href="https://github.com/EndBug/add-and-commit/commits?author=mcargille" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/secondmanveran"><img src="https://avatars.githubusercontent.com/u/97000801?v=4?s=100" width="100px;" alt=""/><br /><sub><b>secondman</b></sub></a><br /><a href="https://github.com/EndBug/add-and-commit/commits?author=secondmanveran" title="Documentation">📖</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><a href="https://github.com/prince-chrismc"><img src="https://avatars.githubusercontent.com/u/16867443?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Chris Mc</b></sub></a><br /><a href="https://github.com/EndBug/add-and-commit/commits?author=prince-chrismc" title="Documentation">📖</a></td>
|
||||
<td align="center"><a href="https://linkedin.com/in/namyalg"><img src="https://avatars.githubusercontent.com/u/53875297?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Namya LG</b></sub></a><br /><a href="https://github.com/EndBug/add-and-commit/commits?author=Namyalg" title="Documentation">📖</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<!-- markdownlint-enable -->
|
||||
<!-- markdownlint-restore -->
|
||||
<!-- 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!
|
||||
|
||||
### Additional credits
|
||||
|
||||
This action is inspired by [`git-auto-commit-action`](https://github.com/stefanzweifel/git-auto-commit-action) by [Stefan Zweifel](https://github.com/stefanzweifel).
|
||||
|
||||
## License
|
||||
|
||||
This action is distributed under the MIT license, check the [license](LICENSE) for more info.
|
||||
|
||||
41
action.yml
41
action.yml
@@ -1,5 +1,5 @@
|
||||
name: Add & Commit
|
||||
description: Add & commit files from a path directly from GitHub Actions
|
||||
description: Automatically commit changes made in your workflow run directly to your repo
|
||||
|
||||
inputs:
|
||||
add:
|
||||
@@ -12,20 +12,36 @@ inputs:
|
||||
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
|
||||
commit:
|
||||
description: Additional arguments for the git commit command
|
||||
required: false
|
||||
committer_name:
|
||||
description: The name of the custom committer you want to use
|
||||
required: false
|
||||
committer_email:
|
||||
description: The email of the custom committer you want to use
|
||||
required: false
|
||||
cwd:
|
||||
description: The directory where your repository is located. You should use actions/checkout first to set it up
|
||||
required: false
|
||||
default: '.'
|
||||
default_author:
|
||||
description: How the action should fill missing author name or email.
|
||||
required: false
|
||||
default: 'github_actor'
|
||||
message:
|
||||
description: The message for the commit
|
||||
required: false
|
||||
pull_strategy:
|
||||
description: The flag used on the pull strategy
|
||||
new_branch:
|
||||
description: The name of the branch to create.
|
||||
required: false
|
||||
pathspec_error_handling:
|
||||
description: The way the action should handle pathspec errors from the add and remove commands.
|
||||
required: false
|
||||
default: ignore
|
||||
pull:
|
||||
description: Arguments for the git pull command. By default, the action does not pull.
|
||||
required: false
|
||||
default: '--no-rebase'
|
||||
push:
|
||||
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)
|
||||
required: false
|
||||
@@ -33,20 +49,23 @@ inputs:
|
||||
remove:
|
||||
description: Arguments for the git rm command
|
||||
required: false
|
||||
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
|
||||
token:
|
||||
description: 'GITHUB_TOKEN or a `repo` scoped Personal Access Token (PAT)'
|
||||
|
||||
# Input not required from the user
|
||||
github_token:
|
||||
description: The token used to make requests to the GitHub API. It's NOT used to make commits and should not be changed.
|
||||
required: false
|
||||
default: ${{ github.token }}
|
||||
|
||||
outputs:
|
||||
committed:
|
||||
description: Whether the action has created a commit.
|
||||
commit_long_sha:
|
||||
description: The complete SHA of the commit that has been created.
|
||||
commit_sha:
|
||||
description: The short SHA of the commit that has been created.
|
||||
pushed:
|
||||
description: Whether the action has pushed to the remote.
|
||||
tagged:
|
||||
|
||||
8
lib/index.js
generated
8
lib/index.js
generated
File diff suppressed because one or more lines are too long
5747
package-lock.json
generated
5747
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
42
package.json
42
package.json
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "add-and-commit",
|
||||
"version": "6.2.0",
|
||||
"version": "8.0.2",
|
||||
"private": true,
|
||||
"description": "Add & commit files from a path directly from GitHub Actions",
|
||||
"main": "lib/index.js",
|
||||
"scripts": {
|
||||
@@ -9,13 +10,9 @@
|
||||
"lint": "eslint --ext .ts src",
|
||||
"lint:fix": "eslint --ext .ts --fix src",
|
||||
"changelog": "ts-node scripts/changelog.ts && npm i",
|
||||
"prepare": "husky install",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "npm run build && git add lib"
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/EndBug/add-and-commit.git"
|
||||
@@ -34,25 +31,26 @@
|
||||
},
|
||||
"homepage": "https://github.com/EndBug/add-and-commit#readme",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.6",
|
||||
"axios": "^0.21.0",
|
||||
"js-yaml": "^3.14.1",
|
||||
"simple-git": "^2.27.0"
|
||||
"@actions/core": "^1.6.0",
|
||||
"actions-toolkit": "github:EndBug/actions-toolkit#core-actions",
|
||||
"js-yaml": "^4.1.0",
|
||||
"simple-git": "^2.27.0",
|
||||
"string-argv": "^0.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/js-yaml": "^3.12.5",
|
||||
"@types/js-yaml": "^4.0.5",
|
||||
"@types/node": "^12.12.54",
|
||||
"@typescript-eslint/eslint-plugin": "^2.34.0",
|
||||
"@typescript-eslint/parser": "^2.34.0",
|
||||
"@vercel/ncc": "^0.26.1",
|
||||
"all-contributors-cli": "^6.19.0",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-config-prettier": "^6.15.0",
|
||||
"eslint-plugin-prettier": "^3.3.0",
|
||||
"husky": "^4.3.6",
|
||||
"prettier": "^2.2.1",
|
||||
"ts-node": "^9.1.1",
|
||||
"typescript": "^4.1.3",
|
||||
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
||||
"@typescript-eslint/parser": "^4.33.0",
|
||||
"@vercel/ncc": "^0.33.1",
|
||||
"all-contributors-cli": "^6.20.0",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
"husky": "^7.0.4",
|
||||
"prettier": "^2.5.1",
|
||||
"ts-node": "^10.4.0",
|
||||
"typescript": "^4.5.5",
|
||||
"yamljs": "^0.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
234
src/io.ts
Normal file
234
src/io.ts
Normal file
@@ -0,0 +1,234 @@
|
||||
import * as core from '@actions/core'
|
||||
import { getUserInfo, parseInputArray } from './util'
|
||||
|
||||
interface InputTypes {
|
||||
add: string
|
||||
author_name: string
|
||||
author_email: string
|
||||
commit: string | undefined
|
||||
committer_name: string
|
||||
committer_email: string
|
||||
cwd: string
|
||||
default_author: 'github_actor' | 'user_info' | 'github_actions'
|
||||
message: string
|
||||
new_branch: string | undefined
|
||||
pathspec_error_handling: 'ignore' | 'exitImmediately' | 'exitAtEnd'
|
||||
pull: string | undefined
|
||||
push: string
|
||||
remove: string | undefined
|
||||
tag: string | undefined
|
||||
|
||||
github_token: string | undefined
|
||||
}
|
||||
export type input = keyof InputTypes
|
||||
|
||||
interface OutputTypes {
|
||||
committed: 'true' | 'false'
|
||||
commit_long_sha: string | undefined
|
||||
commit_sha: string | undefined
|
||||
pushed: 'true' | 'false'
|
||||
tagged: 'true' | 'false'
|
||||
}
|
||||
export type output = keyof OutputTypes
|
||||
|
||||
export const outputs: OutputTypes = {
|
||||
committed: 'false',
|
||||
commit_long_sha: undefined,
|
||||
commit_sha: undefined,
|
||||
pushed: 'false',
|
||||
tagged: 'false'
|
||||
}
|
||||
// Setup default output values
|
||||
Object.entries(outputs).forEach(([name, value]) => core.setOutput(name, value))
|
||||
|
||||
export function getInput<T extends input>(name: T, parseAsBool: true): boolean
|
||||
export function getInput<T extends input>(
|
||||
name: T,
|
||||
parseAsBool?: false
|
||||
): InputTypes[T]
|
||||
export function getInput<T extends input>(
|
||||
name: T,
|
||||
parseAsBool = false
|
||||
): InputTypes[T] | boolean {
|
||||
if (parseAsBool) return core.getBooleanInput(name)
|
||||
// @ts-expect-error
|
||||
return core.getInput(name)
|
||||
}
|
||||
|
||||
export function setOutput<T extends output>(name: T, value: OutputTypes[T]) {
|
||||
core.debug(`Setting output: ${name}=${value}`)
|
||||
outputs[name] = value
|
||||
core.setOutput(name, value)
|
||||
}
|
||||
|
||||
export function logOutputs() {
|
||||
core.startGroup('Outputs')
|
||||
for (const key in outputs) {
|
||||
core.info(`${key}: ${outputs[key]}`)
|
||||
}
|
||||
core.endGroup()
|
||||
}
|
||||
|
||||
export 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)
|
||||
}
|
||||
|
||||
// #region add, remove
|
||||
if (!getInput('add') && !getInput('remove'))
|
||||
throw new Error(
|
||||
"Both 'add' and 'remove' are empty, the action has nothing to do."
|
||||
)
|
||||
|
||||
if (getInput('add')) {
|
||||
const parsed = parseInputArray(getInput('add'))
|
||||
if (parsed.length == 1)
|
||||
core.info('Add input parsed as single string, running 1 git add command.')
|
||||
else if (parsed.length > 1)
|
||||
core.info(
|
||||
`Add input parsed as string array, running ${parsed.length} git add commands.`
|
||||
)
|
||||
else core.setFailed('Add input: array length < 1')
|
||||
}
|
||||
if (getInput('remove')) {
|
||||
const parsed = parseInputArray(getInput('remove') || '')
|
||||
if (parsed.length == 1)
|
||||
core.info(
|
||||
'Remove input parsed as single string, running 1 git rm command.'
|
||||
)
|
||||
else if (parsed.length > 1)
|
||||
core.info(
|
||||
`Remove input parsed as string array, running ${parsed.length} git rm commands.`
|
||||
)
|
||||
else core.setFailed('Remove input: array length < 1')
|
||||
}
|
||||
// #endregion
|
||||
|
||||
// #region default_author
|
||||
const default_author_valid = ['github_actor', 'user_info', 'github_actions']
|
||||
if (!default_author_valid.includes(getInput('default_author')))
|
||||
throw new Error(
|
||||
`'${getInput(
|
||||
'default_author'
|
||||
)}' is not a valid value for default_author. Valid values: ${default_author_valid.join(
|
||||
', '
|
||||
)}`
|
||||
)
|
||||
// #endregion
|
||||
|
||||
// #region author_name, author_email
|
||||
let name, email
|
||||
switch (getInput('default_author')) {
|
||||
case 'github_actor': {
|
||||
name = process.env.GITHUB_ACTOR
|
||||
email = `${process.env.GITHUB_ACTOR}@users.noreply.github.com`
|
||||
break
|
||||
}
|
||||
|
||||
case 'user_info': {
|
||||
if (!getInput('author_name') || !getInput('author_email')) {
|
||||
const res = await getUserInfo(process.env.GITHUB_ACTOR)
|
||||
if (!res?.name)
|
||||
core.warning("Couldn't fetch author name, filling with github_actor.")
|
||||
if (!res?.email)
|
||||
core.warning(
|
||||
"Couldn't fetch author email, filling with github_actor."
|
||||
)
|
||||
|
||||
res?.name && (name = res?.name)
|
||||
res?.email && (email = res.email)
|
||||
if (name && email) break
|
||||
}
|
||||
|
||||
!name && (name = process.env.GITHUB_ACTOR)
|
||||
!email && (email = `${process.env.GITHUB_ACTOR}@users.noreply.github.com`)
|
||||
break
|
||||
}
|
||||
|
||||
case 'github_actions': {
|
||||
name = 'github-actions'
|
||||
email = '41898282+github-actions[bot]@users.noreply.github.com'
|
||||
break
|
||||
}
|
||||
|
||||
default:
|
||||
throw new Error(
|
||||
'This should not happen, please contact the author of this action. (checkInputs.author)'
|
||||
)
|
||||
}
|
||||
|
||||
setDefault('author_name', name)
|
||||
setDefault('author_email', email)
|
||||
core.info(
|
||||
`> Using '${getInput('author_name')} <${getInput(
|
||||
'author_email'
|
||||
)}>' as author.`
|
||||
)
|
||||
// #endregion
|
||||
|
||||
// #region committer_name, committer_email
|
||||
if (getInput('committer_name') || getInput('committer_email'))
|
||||
core.info(
|
||||
`> Using custom committer info: ${
|
||||
getInput('committer_name') ||
|
||||
getInput('author_name') + ' [from author info]'
|
||||
} <${
|
||||
getInput('committer_email') ||
|
||||
getInput('author_email') + ' [from author info]'
|
||||
}>`
|
||||
)
|
||||
|
||||
setDefault('committer_name', getInput('author_name'))
|
||||
setDefault('committer_email', getInput('author_email'))
|
||||
core.debug(
|
||||
`Committer: ${getInput('committer_name')} <${getInput('committer_email')}>`
|
||||
)
|
||||
// #endregion
|
||||
|
||||
// #region message
|
||||
setDefault(
|
||||
'message',
|
||||
`Commit from GitHub Actions (${process.env.GITHUB_WORKFLOW})`
|
||||
)
|
||||
core.info(`> Using "${getInput('message')}" as commit message.`)
|
||||
// #endregion
|
||||
|
||||
// #region pathspec_error_handling
|
||||
const peh_valid = ['ignore', 'exitImmediately', 'exitAtEnd']
|
||||
if (!peh_valid.includes(getInput('pathspec_error_handling')))
|
||||
throw new Error(
|
||||
`"${getInput(
|
||||
'pathspec_error_handling'
|
||||
)}" is not a valid value for the 'pathspec_error_handling' input. Valid values are: ${peh_valid.join(
|
||||
', '
|
||||
)}`
|
||||
)
|
||||
// #endregion
|
||||
|
||||
// #region push
|
||||
if (getInput('push')) {
|
||||
// It has to be either 'true', 'false', or any other string (use as arguments)
|
||||
let value: string | boolean
|
||||
|
||||
try {
|
||||
value = getInput('push', true)
|
||||
} catch {
|
||||
value = getInput('push')
|
||||
}
|
||||
|
||||
core.debug(`Current push option: '${value}' (parsed as ${typeof value})`)
|
||||
}
|
||||
// #endregion
|
||||
|
||||
// #region github_token
|
||||
if (!getInput('github_token'))
|
||||
core.warning(
|
||||
'No github_token has been detected, the action may fail if it needs to use the API'
|
||||
)
|
||||
// #endregion
|
||||
}
|
||||
457
src/main.ts
457
src/main.ts
@@ -1,94 +1,103 @@
|
||||
import {
|
||||
info,
|
||||
setFailed,
|
||||
warning,
|
||||
debug,
|
||||
startGroup,
|
||||
endGroup
|
||||
} from '@actions/core'
|
||||
import axios from 'axios'
|
||||
import * as core from '@actions/core'
|
||||
import path from 'path'
|
||||
import simpleGit, { Response } from 'simple-git'
|
||||
import YAML from 'js-yaml'
|
||||
import { getInput, Input, log, outputs, parseBool, setOutput } from './util'
|
||||
import { checkInputs, getInput, logOutputs, setOutput } from './io'
|
||||
import { log, matchGitArgs, parseInputArray } from './util'
|
||||
|
||||
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...')
|
||||
const exitErrors: Error[] = []
|
||||
|
||||
core.info(`Running in ${baseDir}`)
|
||||
;(async () => {
|
||||
await checkInputs()
|
||||
|
||||
core.startGroup('Internal logs')
|
||||
core.info('> Staging files...')
|
||||
|
||||
const peh = getInput('pathspec_error_handling')
|
||||
|
||||
if (getInput('add')) {
|
||||
info('> Adding files...')
|
||||
await add()
|
||||
} else info('> No files to add.')
|
||||
core.info('> Adding files...')
|
||||
await add(peh == 'ignore' ? 'pathspec' : 'none')
|
||||
} else core.info('> No files to add.')
|
||||
|
||||
if (getInput('remove')) {
|
||||
info('> Removing files...')
|
||||
await remove()
|
||||
} else info('> No files to remove.')
|
||||
core.info('> Removing files...')
|
||||
await remove(peh == 'ignore' ? 'pathspec' : 'none')
|
||||
} else core.info('> No files to remove.')
|
||||
|
||||
info('> Checking for uncommitted changes in the git working tree...')
|
||||
core.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.`)
|
||||
// continue if there are any changes or if the allow-empty commit argument is included
|
||||
if (
|
||||
changedFiles > 0 ||
|
||||
matchGitArgs(getInput('commit') || '').includes('--allow-empty')
|
||||
) {
|
||||
core.info(`> Found ${changedFiles} changed files.`)
|
||||
core.debug(
|
||||
`--allow-empty argument detected: ${matchGitArgs(
|
||||
getInput('commit') || ''
|
||||
).includes('--allow-empty')}`
|
||||
)
|
||||
|
||||
await git
|
||||
.addConfig('user.email', getInput('author_email'), undefined, log)
|
||||
.addConfig('user.name', getInput('author_name'), undefined, log)
|
||||
debug(
|
||||
.addConfig('author.email', getInput('author_email'), undefined, log)
|
||||
.addConfig('author.name', getInput('author_name'), undefined, log)
|
||||
.addConfig('committer.email', getInput('committer_email'), undefined, log)
|
||||
.addConfig('committer.name', getInput('committer_name'), undefined, log)
|
||||
core.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))
|
||||
const targetBranch = getInput('new_branch')
|
||||
if (targetBranch) {
|
||||
await git
|
||||
.checkout(targetBranch)
|
||||
.then(() => {
|
||||
log(undefined, `'${targetBranch}' branch already existed.`)
|
||||
})
|
||||
.catch(() => {
|
||||
log(undefined, `Creating '${targetBranch}' branch.`)
|
||||
return git.checkoutLocalBranch(targetBranch, log)
|
||||
})
|
||||
}
|
||||
|
||||
info('> Pulling from remote...')
|
||||
await git.fetch(undefined, log).pull(
|
||||
undefined,
|
||||
undefined,
|
||||
{
|
||||
[getInput('pull_strategy')]: null
|
||||
},
|
||||
log
|
||||
)
|
||||
const pullOption = getInput('pull')
|
||||
if (pullOption) {
|
||||
core.info('> Pulling from remote...')
|
||||
core.debug(`Current git pull arguments: ${pullOption}`)
|
||||
await git
|
||||
.fetch(undefined, log)
|
||||
.pull(undefined, undefined, matchGitArgs(pullOption), log)
|
||||
} else core.info('> Not pulling from repo.')
|
||||
|
||||
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
|
||||
}
|
||||
: {})
|
||||
},
|
||||
(err, data?) => {
|
||||
if (data) setOutput('committed', 'true')
|
||||
return log(err, data)
|
||||
}
|
||||
)
|
||||
core.info('> Creating commit...')
|
||||
const commitData = await git
|
||||
.commit(getInput('message'), matchGitArgs(getInput('commit') || ''))
|
||||
.catch((err) => {
|
||||
log(err)
|
||||
})
|
||||
if (commitData) {
|
||||
log(undefined, commitData)
|
||||
setOutput('committed', 'true')
|
||||
setOutput('commit_sha', commitData.commit)
|
||||
await git
|
||||
.revparse(commitData.commit)
|
||||
.then((long_sha) => setOutput('commit_long_sha', long_sha))
|
||||
.catch((err) => core.warning(`Couldn't parse long SHA:\n${err}`))
|
||||
}
|
||||
|
||||
if (getInput('tag')) {
|
||||
info('> Tagging commit...')
|
||||
core.info('> Tagging commit...')
|
||||
await git
|
||||
.tag(getInput('tag').split(' '), (err, data?) => {
|
||||
.tag(matchGitArgs(getInput('tag') || ''), (err, data?) => {
|
||||
if (data) setOutput('tagged', 'true')
|
||||
return log(err, data)
|
||||
})
|
||||
@@ -96,19 +105,28 @@ console.log(`Running in ${baseDir}`)
|
||||
setOutput('tagged', 'true')
|
||||
return log(null, data)
|
||||
})
|
||||
.catch((err) => setFailed(err))
|
||||
} else info('> No tag info provided.')
|
||||
.catch((err) => core.setFailed(err))
|
||||
} else core.info('> No tag info provided.')
|
||||
|
||||
const pushOption = parseBool(getInput('push')) ?? getInput('push')
|
||||
let pushOption: string | boolean
|
||||
try {
|
||||
pushOption = getInput('push', true)
|
||||
} catch {
|
||||
pushOption = getInput('push')
|
||||
}
|
||||
if (pushOption) {
|
||||
// If the options is `true | string`...
|
||||
info('> Pushing commit to repo...')
|
||||
core.info('> Pushing commit to repo...')
|
||||
|
||||
if (pushOption === true) {
|
||||
debug(`Running: git push origin ${getInput('branch')} --set-upstream`)
|
||||
core.debug(
|
||||
`Running: git push origin ${
|
||||
getInput('new_branch') || ''
|
||||
} --set-upstream`
|
||||
)
|
||||
await git.push(
|
||||
'origin',
|
||||
getInput('branch'),
|
||||
getInput('new_branch'),
|
||||
{ '--set-upstream': null },
|
||||
(err, data?) => {
|
||||
if (data) setOutput('pushed', 'true')
|
||||
@@ -116,11 +134,11 @@ console.log(`Running in ${baseDir}`)
|
||||
}
|
||||
)
|
||||
} else {
|
||||
debug(`Running: git push ${pushOption}`)
|
||||
core.debug(`Running: git push ${pushOption}`)
|
||||
await git.push(
|
||||
undefined,
|
||||
undefined,
|
||||
pushOption.split(' '),
|
||||
matchGitArgs(pushOption),
|
||||
(err, data?) => {
|
||||
if (data) setOutput('pushed', 'true')
|
||||
return log(err, data)
|
||||
@@ -129,11 +147,13 @@ console.log(`Running in ${baseDir}`)
|
||||
}
|
||||
|
||||
if (getInput('tag')) {
|
||||
info('> Pushing tags to repo...')
|
||||
core.info('> Pushing tags to repo...')
|
||||
await git
|
||||
.pushTags('origin', undefined, (e, d?) => log(undefined, e || d))
|
||||
.catch(() => {
|
||||
info('> Tag push failed: deleting remote tag and re-pushing...')
|
||||
core.info(
|
||||
'> Tag push failed: deleting remote tag and re-pushing...'
|
||||
)
|
||||
return git
|
||||
.push(
|
||||
undefined,
|
||||
@@ -141,193 +161,42 @@ console.log(`Running in ${baseDir}`)
|
||||
{
|
||||
'--delete': null,
|
||||
origin: null,
|
||||
[getInput('tag')
|
||||
.split(' ')
|
||||
.filter((w) => !w.startsWith('-'))[0]]: null
|
||||
[matchGitArgs(getInput('tag') || '').filter(
|
||||
(w) => !w.startsWith('-')
|
||||
)[0]]: null
|
||||
},
|
||||
log
|
||||
)
|
||||
.pushTags('origin', undefined, log)
|
||||
})
|
||||
} else info('> No tags to push.')
|
||||
} else info('> Not pushing anything.')
|
||||
} else core.info('> No tags to push.')
|
||||
} else core.info('> Not pushing anything.')
|
||||
|
||||
endGroup()
|
||||
info('> Task completed.')
|
||||
core.endGroup()
|
||||
core.info('> Task completed.')
|
||||
} else {
|
||||
endGroup()
|
||||
info('> Working tree clean. Nothing to commit.')
|
||||
core.endGroup()
|
||||
core.info('> Working tree clean. Nothing to commit.')
|
||||
}
|
||||
})()
|
||||
.then(() => {
|
||||
// Check for exit errors
|
||||
if (exitErrors.length == 1) throw exitErrors[0]
|
||||
else if (exitErrors.length > 1) {
|
||||
exitErrors.forEach((e) => core.error(e))
|
||||
throw 'There have been multiple runtime errors.'
|
||||
}
|
||||
})
|
||||
.then(logOutputs)
|
||||
.catch((e) => {
|
||||
endGroup()
|
||||
core.endGroup()
|
||||
logOutputs()
|
||||
setFailed(e)
|
||||
core.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),
|
||||
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
|
||||
let token = process.env.GITHUB_TOKEN
|
||||
if (token) {
|
||||
debug('Using token from GITHUB_TOKEN env variable.')
|
||||
warning(
|
||||
"The GITHUB_TOKEN env variable is deprecated and will not be supported in the next major release. Use the 'token' input, " +
|
||||
"which defaults to 'secrets.GITHUB_TOKEN'."
|
||||
)
|
||||
} else {
|
||||
debug('Using token from token input.')
|
||||
token = getInput('token')
|
||||
}
|
||||
// #endregion
|
||||
|
||||
// #region add, remove
|
||||
if (!getInput('add') && !getInput('remove'))
|
||||
throw new Error(
|
||||
"Both 'add' and 'remove' are empty, the action has nothing to do."
|
||||
)
|
||||
|
||||
if (getInput('add')) {
|
||||
const parsed = parseInputArray(getInput('add'))
|
||||
if (parsed.length == 1)
|
||||
info('Add input parsed as single string, running 1 git add command.')
|
||||
else if (parsed.length > 1)
|
||||
info(
|
||||
`Add input parsed as string array, running ${parsed.length} git add commands.`
|
||||
)
|
||||
else setFailed('Add input: array length < 1')
|
||||
}
|
||||
if (getInput('remove')) {
|
||||
const parsed = parseInputArray(getInput('remove'))
|
||||
if (parsed.length == 1)
|
||||
info('Remove input parsed as single string, running 1 git rm command.')
|
||||
else if (parsed.length > 1)
|
||||
info(
|
||||
`Remove input parsed as string array, running ${parsed.length} git rm commands.`
|
||||
)
|
||||
else setFailed('Remove input: array length < 1')
|
||||
}
|
||||
// #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)
|
||||
}
|
||||
|
||||
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')
|
||||
}
|
||||
|
||||
info(
|
||||
`> Using '${getInput('author_name')} <${getInput(
|
||||
'author_email'
|
||||
)}>' as author.`
|
||||
)
|
||||
// #endregion
|
||||
|
||||
// #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')) {
|
||||
const parsed = parseBool(getInput('signoff'))
|
||||
|
||||
if (parsed === undefined)
|
||||
throw new Error(
|
||||
`"${getInput(
|
||||
'signoff'
|
||||
)}" is not a valid value for the 'signoff' input: only "true" and "false" are allowed.`
|
||||
)
|
||||
|
||||
if (!parsed) setInput('signoff', undefined)
|
||||
|
||||
debug(
|
||||
`Current signoff option: ${getInput('signoff')} (${typeof getInput(
|
||||
'signoff'
|
||||
)})`
|
||||
)
|
||||
}
|
||||
// #endregion
|
||||
|
||||
// #region push
|
||||
if (getInput('push')) {
|
||||
// It has to be either 'true', 'false', or any other string (use as arguments)
|
||||
const parsed = parseBool(getInput('push'))
|
||||
|
||||
debug(
|
||||
`Current push option: '${getInput('push')}' (parsed as ${typeof parsed})`
|
||||
)
|
||||
}
|
||||
// #endregion
|
||||
}
|
||||
|
||||
async function add({ logWarning = true, ignoreErrors = false } = {}): Promise<
|
||||
(void | Response<void>)[]
|
||||
> {
|
||||
async function add(
|
||||
ignoreErrors: 'all' | 'pathspec' | 'none' = 'none'
|
||||
): Promise<(void | Response<void>)[]> {
|
||||
const input = getInput('add')
|
||||
if (!input) return []
|
||||
|
||||
@@ -339,18 +208,27 @@ async function add({ logWarning = true, ignoreErrors = false } = {}): Promise<
|
||||
// Push the result of every git command (which are executed in order) to the array
|
||||
// If any of them fails, the whole function will return a Promise rejection
|
||||
await git
|
||||
.add(args.split(' '), (err: any, data?: any) =>
|
||||
log(ignoreErrors ? null : err, data)
|
||||
.add(matchGitArgs(args), (err: any, data?: any) =>
|
||||
log(ignoreErrors == 'all' ? null : err, data)
|
||||
)
|
||||
.catch((e: Error) => {
|
||||
if (ignoreErrors) return
|
||||
// if I should ignore every error, return
|
||||
if (ignoreErrors == 'all') return
|
||||
|
||||
// if it's a pathspec error...
|
||||
if (
|
||||
e.message.includes('fatal: pathspec') &&
|
||||
e.message.includes('did not match any files') &&
|
||||
logWarning
|
||||
)
|
||||
warning(`Add command did not match any file:\n git add ${args}`)
|
||||
else throw e
|
||||
e.message.includes('did not match any files')
|
||||
) {
|
||||
if (ignoreErrors == 'pathspec') return
|
||||
|
||||
const peh = getInput('pathspec_error_handling'),
|
||||
err = new Error(
|
||||
`Add command did not match any file: git add ${args}`
|
||||
)
|
||||
if (peh == 'exitImmediately') throw err
|
||||
if (peh == 'exitAtEnd') exitErrors.push(err)
|
||||
} else throw e
|
||||
})
|
||||
)
|
||||
}
|
||||
@@ -358,10 +236,9 @@ async function add({ logWarning = true, ignoreErrors = false } = {}): Promise<
|
||||
return res
|
||||
}
|
||||
|
||||
async function remove({
|
||||
logWarning = true,
|
||||
ignoreErrors = false
|
||||
} = {}): Promise<(void | Response<void>)[]> {
|
||||
async function remove(
|
||||
ignoreErrors: 'all' | 'pathspec' | 'none' = 'none'
|
||||
): Promise<(void | Response<void>)[]> {
|
||||
const input = getInput('remove')
|
||||
if (!input) return []
|
||||
|
||||
@@ -373,64 +250,30 @@ async function remove({
|
||||
// Push the result of every git command (which are executed in order) to the array
|
||||
// If any of them fails, the whole function will return a Promise rejection
|
||||
await git
|
||||
.rm(args.split(' '), (e: any, d?: any) =>
|
||||
log(ignoreErrors ? null : e, d)
|
||||
.rm(matchGitArgs(args), (e: any, d?: any) =>
|
||||
log(ignoreErrors == 'all' ? null : e, d)
|
||||
)
|
||||
.catch((e: Error) => {
|
||||
if (ignoreErrors) return
|
||||
// if I should ignore every error, return
|
||||
if (ignoreErrors == 'all') return
|
||||
|
||||
// if it's a pathspec error...
|
||||
if (
|
||||
e.message.includes('fatal: pathspec') &&
|
||||
e.message.includes('did not match any files')
|
||||
)
|
||||
logWarning &&
|
||||
warning(
|
||||
) {
|
||||
if (ignoreErrors == 'pathspec') return
|
||||
|
||||
const peh = getInput('pathspec_error_handling'),
|
||||
err = new Error(
|
||||
`Remove command did not match any file:\n git rm ${args}`
|
||||
)
|
||||
else throw e
|
||||
if (peh == 'exitImmediately') throw err
|
||||
if (peh == 'exitAtEnd') exitErrors.push(err)
|
||||
} else throw e
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to parse a JSON array, then a YAML array.
|
||||
* If both fail, it returns an array containing the input value as its only element
|
||||
*/
|
||||
function parseInputArray(input: string): string[] {
|
||||
try {
|
||||
const json = JSON.parse(input)
|
||||
if (
|
||||
json &&
|
||||
Array.isArray(json) &&
|
||||
json.every((e) => typeof e == 'string')
|
||||
) {
|
||||
debug(`Input parsed as JSON array of length ${json.length}`)
|
||||
return json
|
||||
}
|
||||
} catch {}
|
||||
|
||||
try {
|
||||
const yaml = YAML.safeLoad(input)
|
||||
if (
|
||||
yaml &&
|
||||
Array.isArray(yaml) &&
|
||||
yaml.every((e) => typeof e == 'string')
|
||||
) {
|
||||
debug(`Input parsed as YAML array of length ${yaml.length}`)
|
||||
return yaml
|
||||
}
|
||||
} catch {}
|
||||
|
||||
debug('Input parsed as single string')
|
||||
return [input]
|
||||
}
|
||||
|
||||
function logOutputs() {
|
||||
startGroup('Outputs')
|
||||
for (const key in outputs) {
|
||||
info(`${key}: ${outputs[key]}`)
|
||||
}
|
||||
endGroup()
|
||||
}
|
||||
|
||||
134
src/util.ts
134
src/util.ts
@@ -1,28 +1,33 @@
|
||||
import { parseArgsStringToArgv } from 'string-argv'
|
||||
import * as core from '@actions/core'
|
||||
import YAML from 'js-yaml'
|
||||
import { Toolkit } from 'actions-toolkit'
|
||||
import fs from 'fs'
|
||||
import { input, output } from './io'
|
||||
|
||||
export type Input =
|
||||
| 'add'
|
||||
| 'author_name'
|
||||
| 'author_email'
|
||||
| 'branch'
|
||||
| 'cwd'
|
||||
| 'message'
|
||||
| 'pull_strategy'
|
||||
| 'push'
|
||||
| 'remove'
|
||||
| 'signoff'
|
||||
| 'tag'
|
||||
| 'token'
|
||||
type RecordOf<T extends string> = Record<T, string | undefined>
|
||||
export const tools = new Toolkit<RecordOf<input>, RecordOf<output>>({
|
||||
secrets: [
|
||||
'GITHUB_EVENT_PATH',
|
||||
'GITHUB_EVENT_NAME',
|
||||
'GITHUB_REF',
|
||||
'GITHUB_ACTOR'
|
||||
]
|
||||
})
|
||||
|
||||
export const outputs = {
|
||||
committed: 'false',
|
||||
pushed: 'false',
|
||||
tagged: 'false'
|
||||
}
|
||||
export type Output = keyof typeof outputs
|
||||
export async function getUserInfo(username?: string) {
|
||||
if (!username) return undefined
|
||||
|
||||
export function getInput(name: Input) {
|
||||
return core.getInput(name)
|
||||
const res = await tools.github.users.getByUsername({ username })
|
||||
|
||||
core.debug(
|
||||
`Fetched github actor from the API: ${JSON.stringify(res?.data, null, 2)}`
|
||||
)
|
||||
|
||||
return {
|
||||
name: res?.data?.name,
|
||||
email: res?.data?.email
|
||||
}
|
||||
}
|
||||
|
||||
export function log(err: any | Error, data?: any) {
|
||||
@@ -30,16 +35,83 @@ export function log(err: any | Error, data?: any) {
|
||||
if (err) core.error(err)
|
||||
}
|
||||
|
||||
export function parseBool(value: any) {
|
||||
try {
|
||||
const parsed = JSON.parse(value)
|
||||
if (typeof parsed == 'boolean') return parsed
|
||||
} catch {}
|
||||
/**
|
||||
* Matches the given string to an array of arguments.
|
||||
* The parsing is made by `string-argv`: if your way of using argument is not supported, the issue is theirs!
|
||||
* {@link https://www.npm.im/string-argv}
|
||||
* @example
|
||||
* ```js
|
||||
* matchGitArgs(`
|
||||
-s
|
||||
--longOption 'This uses the "other" quotes'
|
||||
--foo 1234
|
||||
--file=message.txt
|
||||
--file2="Application 'Support'/\"message\".txt"
|
||||
`) => [
|
||||
'-s',
|
||||
'--longOption',
|
||||
'This uses the "other" quotes',
|
||||
'--foo',
|
||||
'1234',
|
||||
'--file=message.txt',
|
||||
`--file2="Application 'Support'/\\"message\\".txt"`
|
||||
]
|
||||
* matchGitArgs(' ') => [ ]
|
||||
* ```
|
||||
* @returns An array, if there's no match it'll be empty
|
||||
*/
|
||||
export function matchGitArgs(string: string) {
|
||||
const parsed = parseArgsStringToArgv(string)
|
||||
core.debug(`Git args parsed:
|
||||
- Original: ${string}
|
||||
- Parsed: ${JSON.stringify(parsed)}`)
|
||||
return parsed
|
||||
}
|
||||
|
||||
export function setOutput(name: Output, value: 'true' | 'false') {
|
||||
core.debug(`Setting output: ${name}=${value}`)
|
||||
outputs[name] = value
|
||||
return core.setOutput(name, value)
|
||||
/**
|
||||
* Tries to parse a JSON array, then a YAML array.
|
||||
* If both fail, it returns an array containing the input value as its only element
|
||||
*/
|
||||
export function parseInputArray(input: string): string[] {
|
||||
try {
|
||||
const json = JSON.parse(input)
|
||||
if (
|
||||
json &&
|
||||
Array.isArray(json) &&
|
||||
json.every((e) => typeof e == 'string')
|
||||
) {
|
||||
core.debug(`Input parsed as JSON array of length ${json.length}`)
|
||||
return json
|
||||
}
|
||||
} catch {}
|
||||
|
||||
try {
|
||||
const yaml = YAML.load(input)
|
||||
if (
|
||||
yaml &&
|
||||
Array.isArray(yaml) &&
|
||||
yaml.every((e) => typeof e == 'string')
|
||||
) {
|
||||
core.debug(`Input parsed as YAML array of length ${yaml.length}`)
|
||||
return yaml
|
||||
}
|
||||
} catch {}
|
||||
|
||||
core.debug('Input parsed as single string')
|
||||
return [input]
|
||||
}
|
||||
|
||||
export function readJSON(filePath: string) {
|
||||
let fileContent: string
|
||||
try {
|
||||
fileContent = fs.readFileSync(filePath, { encoding: 'utf8' })
|
||||
} catch {
|
||||
throw `Couldn't read file. File path: ${filePath}`
|
||||
}
|
||||
|
||||
try {
|
||||
return JSON.parse(fileContent)
|
||||
} catch {
|
||||
throw `Couldn't parse file to JSON. File path: ${filePath}`
|
||||
}
|
||||
}
|
||||
for (const key in outputs) setOutput(key as Output, outputs[key])
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
||||
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
||||
/* Module Resolution Options */
|
||||
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
||||
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
||||
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
||||
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
||||
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||
|
||||
Reference in New Issue
Block a user