Compare commits
190 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
dbf207a670 | ||
|
|
234011c0f7 | ||
|
|
a536a7f5fc | ||
|
|
951eefe413 | ||
|
|
d7568d6287 | ||
|
|
a837bd27d9 | ||
|
|
9986de0edd | ||
|
|
a51640c51f | ||
|
|
d1d225c38f | ||
|
|
a26f63b0ce | ||
|
|
a71372f9dd | ||
|
|
7bdc8af1b2 | ||
|
|
5c9f1f7cef | ||
|
|
d84d80e417 | ||
|
|
4d73263e3e | ||
|
|
b8f7f0eada | ||
|
|
75a30a545a | ||
|
|
401756f9f0 | ||
|
|
21ed6afecd | ||
|
|
388ce4f475 | ||
|
|
a2ca498476 | ||
|
|
60e7d47c17 | ||
|
|
4215dc951b | ||
|
|
33836ed288 | ||
|
|
6fcd798e4a | ||
|
|
50a62d9e15 | ||
|
|
9e04524704 | ||
|
|
6f812a4e2c | ||
|
|
f11ed1f3d2 | ||
|
|
ab2f7e88a9 | ||
|
|
7209b6038a | ||
|
|
b17846f438 | ||
|
|
da58dc8f9a | ||
|
|
4e0f991445 | ||
|
|
b71678be3e | ||
|
|
f21bebd7d3 | ||
|
|
d0143fb99e | ||
|
|
d192ad0aba | ||
|
|
3bee5aeb33 | ||
|
|
5cb8787442 | ||
|
|
334c6c32a5 | ||
|
|
d4b7879e16 | ||
|
|
d8573f888f | ||
|
|
cac5e6ba5b | ||
|
|
655a68b116 | ||
|
|
524f96d401 | ||
|
|
28ab8fcce3 | ||
|
|
6da0ea7f9b | ||
|
|
11a529635a | ||
|
|
bc31c50167 | ||
|
|
07e991cfab | ||
|
|
0f3c8c6996 | ||
|
|
0f070625cd | ||
|
|
ed8cbae509 | ||
|
|
4b5a2df0dd | ||
|
|
c8e1fb0d1b | ||
|
|
fe1fb219a6 | ||
|
|
28fa18d5af | ||
|
|
a0873811e5 | ||
|
|
40e84d601c | ||
|
|
ec13f51fd9 | ||
|
|
3140d34146 | ||
|
|
3ed8463058 | ||
|
|
ea1d3cefff | ||
|
|
e298441a67 | ||
|
|
4387feb4b8 | ||
|
|
cfa65e13b2 | ||
|
|
eb9afeffe2 | ||
|
|
110b7e289f | ||
|
|
57c075ed5f | ||
|
|
dd36cc6914 | ||
|
|
15f07d3078 | ||
|
|
c0c96adb24 | ||
|
|
b36969554e | ||
|
|
0c6f4a1284 | ||
|
|
9358097a71 | ||
|
|
ed17cacb74 | ||
|
|
e0cd865b68 | ||
|
|
ed7b74af50 | ||
|
|
8c0903ea07 | ||
|
|
29856365a6 | ||
|
|
a7661122af | ||
|
|
1181181b70 | ||
|
|
32090e561e | ||
|
|
07a46e3fca | ||
|
|
b43e3143da | ||
|
|
9c99934303 | ||
|
|
34757b89f7 | ||
|
|
e3b93a10e2 | ||
|
|
b043969cfd | ||
|
|
101829e6c0 | ||
|
|
8cd8f9f071 | ||
|
|
c010bcbe2f | ||
|
|
1b176ae96b | ||
|
|
ecdc355d15 | ||
|
|
79fae44cb3 | ||
|
|
34b3c277a4 | ||
|
|
bd911ffe7e | ||
|
|
e6f30b78b7 | ||
|
|
9145a27b50 |
@@ -144,9 +144,112 @@
|
||||
"name": "Benedek Kozma",
|
||||
"avatar_url": "https://avatars1.githubusercontent.com/u/8356175?v=4",
|
||||
"profile": "https://github.com/Cyberbeni",
|
||||
"contributions": [
|
||||
"ideas",
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "coffeegoddd",
|
||||
"name": "Dustin Brown",
|
||||
"avatar_url": "https://avatars3.githubusercontent.com/u/43383835?v=4",
|
||||
"profile": "https://github.com/coffeegoddd",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "Chocrates",
|
||||
"name": "Chris McIntosh",
|
||||
"avatar_url": "https://avatars1.githubusercontent.com/u/1758164?v=4",
|
||||
"profile": "https://github.com/Chocrates",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "kbsali",
|
||||
"name": "Kevin Saliou",
|
||||
"avatar_url": "https://avatars0.githubusercontent.com/u/53676?v=4",
|
||||
"profile": "https://github.com/kbsali",
|
||||
"contributions": [
|
||||
"ideas"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "ewjoachim",
|
||||
"name": "Joachim Jablon",
|
||||
"avatar_url": "https://avatars0.githubusercontent.com/u/1457576?v=4",
|
||||
"profile": "https://github.com/ewjoachim",
|
||||
"contributions": [
|
||||
"ideas"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "trallnag",
|
||||
"name": "Tim Schwenke",
|
||||
"avatar_url": "https://avatars3.githubusercontent.com/u/24834206?v=4",
|
||||
"profile": "https://github.com/trallnag",
|
||||
"contributions": [
|
||||
"ideas"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "PssbleTrngle",
|
||||
"name": "Possible Triangle",
|
||||
"avatar_url": "https://avatars1.githubusercontent.com/u/12880806?v=4",
|
||||
"profile": "https://www.somethingcatchy.net",
|
||||
"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"
|
||||
]
|
||||
}
|
||||
],
|
||||
"contributorsPerLine": 7,
|
||||
|
||||
64
.eslintrc
64
.eslintrc
@@ -1,64 +0,0 @@
|
||||
{
|
||||
"env": {
|
||||
"node": true,
|
||||
"browser": true,
|
||||
"amd": true,
|
||||
"es6": true
|
||||
},
|
||||
"root": true,
|
||||
"extends": [
|
||||
"eslint:recommended"
|
||||
],
|
||||
"plugins": [
|
||||
"@typescript-eslint"
|
||||
],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 6,
|
||||
"sourceType": "module",
|
||||
"ecmaFeatures": {
|
||||
"jsx": true
|
||||
}
|
||||
},
|
||||
"rules": {
|
||||
"no-cond-assign": [
|
||||
2,
|
||||
"except-parens"
|
||||
],
|
||||
"no-use-before-define": [
|
||||
2,
|
||||
{
|
||||
"functions": false,
|
||||
"classes": false,
|
||||
"variables": false
|
||||
}
|
||||
],
|
||||
"new-cap": 0,
|
||||
"no-caller": 2,
|
||||
"no-undef": 2,
|
||||
"no-unused-vars": 0,
|
||||
"@typescript-eslint/no-unused-vars": "warn",
|
||||
"no-empty": [
|
||||
"error",
|
||||
{
|
||||
"allowEmptyCatch": true
|
||||
}
|
||||
],
|
||||
"no-console": "off",
|
||||
"prefer-const": [
|
||||
"warn",
|
||||
{
|
||||
"destructuring": "all"
|
||||
}
|
||||
],
|
||||
"quotes": [
|
||||
"warn",
|
||||
"single"
|
||||
],
|
||||
"semi": [
|
||||
"warn",
|
||||
"never"
|
||||
],
|
||||
"spaced-comment": "warn"
|
||||
}
|
||||
}
|
||||
35
.eslintrc.js
Normal file
35
.eslintrc.js
Normal file
@@ -0,0 +1,35 @@
|
||||
module.exports = {
|
||||
env: {
|
||||
commonjs: true,
|
||||
es6: true,
|
||||
node: true
|
||||
},
|
||||
extends: ['eslint:recommended', 'plugin:prettier/recommended'],
|
||||
globals: {},
|
||||
parser: '@typescript-eslint/parser',
|
||||
parserOptions: {
|
||||
ecmaVersion: 6,
|
||||
sourceType: 'module'
|
||||
},
|
||||
plugins: ['@typescript-eslint'],
|
||||
ignorePatterns: ['lib/*'],
|
||||
rules: {
|
||||
'prettier/prettier': 'warn',
|
||||
'no-cond-assign': [2, 'except-parens'],
|
||||
'no-unused-vars': 0,
|
||||
'@typescript-eslint/no-unused-vars': 1,
|
||||
'no-empty': [
|
||||
'error',
|
||||
{
|
||||
allowEmptyCatch: true
|
||||
}
|
||||
],
|
||||
'prefer-const': [
|
||||
'warn',
|
||||
{
|
||||
destructuring: 'all'
|
||||
}
|
||||
],
|
||||
'spaced-comment': 'warn'
|
||||
}
|
||||
}
|
||||
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']
|
||||
10
.github/ISSUE_TEMPLATE/blank-issue.md
vendored
Normal file
10
.github/ISSUE_TEMPLATE/blank-issue.md
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
---
|
||||
name: Blank issue
|
||||
about: Just a blank template
|
||||
title: ''
|
||||
labels: 'status: pending'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
|
||||
24
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
24
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Report an issue with the action
|
||||
title: ''
|
||||
labels: 'status: pending'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is. If a particular error is shown
|
||||
|
||||
**Workflow used**
|
||||
Provide a snippet of the workflow and/or a link to it (use the commit sha as the ref when you link it, so that it's not influenced by other changes). If you only share a section of the workflow, make sure it includes the step that uses the action!
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Logs**
|
||||
Either provide a link to the action run or (if your repo is private) paste here the logs from the step that uses it. If you paste the logs, please use this template, and remember to paste the logs from all the different sections.
|
||||
<details>
|
||||
<summary>Logs</summary>
|
||||
<pre><code>Your logs here.</code></pre>
|
||||
</details>
|
||||
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
blank_issues_enabled: false
|
||||
10
.github/ISSUE_TEMPLATE/question.md
vendored
Normal file
10
.github/ISSUE_TEMPLATE/question.md
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
---
|
||||
name: Question
|
||||
about: Ask a question on how to use the action
|
||||
title: ''
|
||||
labels: 'type: question'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
|
||||
16
.github/dependabot.yml
vendored
Normal file
16
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
# To get started with Dependabot version updates, you'll need to specify which
|
||||
# package ecosystems to update and where the package manifests are located.
|
||||
# Please see the documentation for all configuration options:
|
||||
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: 'npm' # See documentation for possible values
|
||||
directory: '/' # Location of package manifests
|
||||
schedule:
|
||||
interval: 'weekly'
|
||||
commit-message:
|
||||
prefix: 'chore'
|
||||
include: 'scope'
|
||||
labels:
|
||||
- 'type: chore'
|
||||
74
.github/labels.yml
vendored
Normal file
74
.github/labels.yml
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
- name: 'good first issue'
|
||||
color: '5319e7'
|
||||
description: 'Good for newcomers'
|
||||
aliases: []
|
||||
|
||||
- name: 'help wanted'
|
||||
color: '008672'
|
||||
description: 'Extra attention is needed'
|
||||
aliases: []
|
||||
|
||||
- name: 'status: pending'
|
||||
color: c5def5
|
||||
description: 'More info is needed before deciding what to do'
|
||||
aliases: []
|
||||
|
||||
- name: 'status: pinned'
|
||||
color: 0052cc
|
||||
description: 'Should not be labeled as stale'
|
||||
aliases: []
|
||||
|
||||
- name: 'status: stale'
|
||||
color: fbca04
|
||||
description: 'Inactive issues and PRs'
|
||||
aliases: ['stale']
|
||||
|
||||
- name: 'status: wontfix'
|
||||
color: cfd3d7
|
||||
description: 'This will not be worked on'
|
||||
aliases: ['wontfix']
|
||||
|
||||
- name: 'type: bug'
|
||||
color: d73a4a
|
||||
description: 'Verified problems that need to be worked on'
|
||||
aliases: ['bug']
|
||||
|
||||
- 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'
|
||||
aliases: ['duplicate']
|
||||
|
||||
- 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"
|
||||
aliases: ['invalid']
|
||||
|
||||
- name: 'type: not a bug'
|
||||
color: 0e8a16
|
||||
description: 'Reports that happen not be our fault'
|
||||
aliases: ['not a bug']
|
||||
|
||||
- name: 'type: question'
|
||||
color: d876e3
|
||||
description: 'Further information is requested'
|
||||
aliases: ['question']
|
||||
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
|
||||
10
.github/workflows/build.yml
vendored
10
.github/workflows/build.yml
vendored
@@ -1,6 +1,8 @@
|
||||
name: Build
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- src/**
|
||||
- .github/workflows/build.yml
|
||||
@@ -25,13 +27,5 @@ jobs:
|
||||
with:
|
||||
message: '[auto] build: update compiled version'
|
||||
add: lib
|
||||
force: true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- uses: EndBug/add-and-commit@v4
|
||||
with:
|
||||
message: '[auto] build: update input typings'
|
||||
add: src/inputs.ts
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
29
.github/workflows/docs.yml
vendored
29
.github/workflows/docs.yml
vendored
@@ -1,29 +0,0 @@
|
||||
name: Docs
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- .all-contributorsrc
|
||||
- .github/workflows/docs.yml
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
contributors:
|
||||
name: Update contributors badge
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 12.x
|
||||
|
||||
- run: npm install
|
||||
|
||||
- run: npm run all-contributors-badge
|
||||
|
||||
- uses: EndBug/add-and-commit@v4.0.0
|
||||
with:
|
||||
message: "[auto] docs: update contributors badge"
|
||||
add: README.md
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
21
.github/workflows/export-labels.yml
vendored
Normal file
21
.github/workflows/export-labels.yml
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
name: Export label config
|
||||
on:
|
||||
# You can run this with every event, but it's better to run it only when you actually need it.
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
labels:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: EndBug/export-label-config@main
|
||||
with:
|
||||
# This is needed if you're dealing with private repos.
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# Set this to `true` if you want to get the raw API reponse. Defaults to `false`.
|
||||
raw-result: false
|
||||
|
||||
# By default every label entry will have an `aliases` property set to an empty array.
|
||||
# It's for EndBug/label-sync, if you don't want it you cans set this to `false`
|
||||
add-aliases: true
|
||||
19
.github/workflows/label-sync.yml
vendored
Normal file
19
.github/workflows/label-sync.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
name: Sync labels
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- '.github/labels.yml'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
sync:
|
||||
name: Run EndBug/label-sync
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: EndBug/label-sync@v1
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
config-file: '.github/labels.yml'
|
||||
21
.github/workflows/stale.yml
vendored
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
|
||||
22
.github/workflows/test.yml
vendored
Normal file
22
.github/workflows/test.yml
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
name: Test
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Test build
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: npm i
|
||||
- run: npm run build
|
||||
|
||||
lint:
|
||||
name: Check linting
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: npm i
|
||||
- run: npm run lint
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,2 @@
|
||||
node_modules
|
||||
build
|
||||
lib
|
||||
|
||||
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
|
||||
7
.prettierrc
Normal file
7
.prettierrc
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"semi": false,
|
||||
"singleQuote": true,
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"trailingComma": "none"
|
||||
}
|
||||
159
CHANGELOG.md
159
CHANGELOG.md
@@ -1,4 +1,5 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
@@ -6,113 +7,248 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [5.1.0] - 2020-10-07
|
||||
## [7.2.1] - 2021-05-11
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Fixed an issue with missing outputs (#189)
|
||||
|
||||
## [7.2.0] - 2021-04-22
|
||||
|
||||
### Added:
|
||||
- The default commit message now displays the name of the workflow too (issue #64)
|
||||
|
||||
- `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:
|
||||
|
||||
- `push` input: allow for custom `git push` arguments to be used, more info in the README. (issue #100)
|
||||
|
||||
## [6.1.0] - 2020-12-22
|
||||
|
||||
### Added:
|
||||
|
||||
- `token` input: you can now use this instead of setting the `GITHUB_TOKEN` env variable, which has been deprecated. This input is optional, its default value is the default `secrets.GITHUB_TOKEN`. You only need to use this if you want the action to run with a PAT. (issue #110)
|
||||
|
||||
### Deprecated:
|
||||
|
||||
- `GITHUB_TOKEN`: the use of this env variable is now deprecated in favor of the `token` input, you'll start receiving warnings if you keep using it. (issue #110)
|
||||
|
||||
## [6.0.0] - 2020-12-22
|
||||
|
||||
### Added:
|
||||
|
||||
- (BREAKING?) Multiple git commands: support JSON/YAML arrays for the `add` and `remove` parameters (you still need pass a string as input, but that can be parsed to an array by the action). Using them will run multiple commands in succession. I don't think this will be really breaking anything, but I've used a major version change just to be sure. There's more info about this stuff on the README. (issue #95)
|
||||
|
||||
## [5.3.0] - 2020-12-12
|
||||
|
||||
### Added:
|
||||
|
||||
- Outputs: the action now has 3 outputs (`committed`, `pushed`, and `tagged`) that will be set to either `true` or `false` to tell you what the action has done. The outputs are also shown in the action logs.
|
||||
|
||||
## [5.2.0] - 2020-11-11
|
||||
|
||||
### Added:
|
||||
|
||||
- New `push` option: this lets you tell the action whether to push commit and tags to the repo. The default value is `true`, so that the default behavior is not changed. (issue #86)
|
||||
|
||||
## [5.1.2] - 2020-11-10
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Fixed an issue with the build (issue #88)
|
||||
|
||||
## [5.1.1] - 2020-11-07
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Fixed typo in parameter name: `pull_strategy` was written as `pull_stategy` (PR #83)
|
||||
|
||||
## [5.1.0] - 2020-10-07
|
||||
|
||||
### Added:
|
||||
|
||||
- The default commit message now displays the name of the workflow too (issue #64)
|
||||
|
||||
## [5.0.0] - 2020-09-27
|
||||
|
||||
### Changed:
|
||||
|
||||
- **[BREAKING]** Action parameters: multiple action parameters have been changed, refer to the docs for better info
|
||||
- The code is now entirely in TypeScript (PR #57)
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Improved input checks
|
||||
- Logs are now displayed on Windows too
|
||||
- Remove unnecessary steps
|
||||
- Remove unused dependencies
|
||||
|
||||
## [4.4.0] - 2020-07-31
|
||||
|
||||
### Added:
|
||||
|
||||
- Pull requests: the action can now work in runs triggered by pull request events (issue #48)
|
||||
|
||||
## [4.3.0] - 2020-07-29
|
||||
|
||||
### Addded:
|
||||
|
||||
- `signoff` parameter: lets you use the `--signoff` argument for the `git commit` command (PR #46)
|
||||
|
||||
## [4.2.1] - 2020-07-10
|
||||
|
||||
### Fixed:
|
||||
|
||||
- OS-support: the action now properly works on Windows instances (issue #33)
|
||||
|
||||
## [4.2.0] - 2020-05-17
|
||||
|
||||
### Added:
|
||||
|
||||
- Tagging: you can now create and update lightweight tags (PR #30)
|
||||
|
||||
## [4.1.0] - 2020-05-01
|
||||
### Added:
|
||||
|
||||
### Added:
|
||||
|
||||
- `ref` parameter: lets you choose the branch to run the action on, the default is the one that triggered the workflow (issue #29)
|
||||
|
||||
## [4.0.3] - 2020-05-01
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Logs: `git diff` won't display logs anymore, to avoid buffer problems (issue #27)
|
||||
- Logs: additional info will be logged along with the command outputs
|
||||
- Logs: added groups to improve readability
|
||||
|
||||
## [4.0.2] - 2020-04-19
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Error handling: failures are now easier to read (issue #25)
|
||||
|
||||
## [4.0.1] - 2020-03-20
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Scheduled events: the action can be used in action runs triggered by a scheduled events
|
||||
- Warnings: there won't be warnings when both `author_name` and `author_email` are set
|
||||
|
||||
## [4.0.0] - 2020-03-03
|
||||
|
||||
### Removed:
|
||||
|
||||
- **[BREAKING]** `path` parameter: see 'Changed' section for more info
|
||||
- **[BREAKING]** `pattern` parameter: see 'Changed' section for more info
|
||||
|
||||
### Changed:
|
||||
|
||||
- The action now uses `git add` and `git rm` commands, you can choose their arguemnts directly by using the `add` and `remove` parameters
|
||||
- **[BREAKING]** Error handling: the action won't stop if one of your git commands fails (e.g. if one of your pathspecs doesn't match any file)
|
||||
|
||||
## [3.1.0] - 2020-02-21
|
||||
|
||||
### Added:
|
||||
|
||||
- `remove` parameter: lets you delete files directly from the action
|
||||
|
||||
## [3.0.0] - 2020-01-24
|
||||
|
||||
### Added:
|
||||
|
||||
- The action can now run in multiple subsequent jobs in the same workflow
|
||||
|
||||
### Removed:
|
||||
|
||||
- **[BREAKING]** [`actions/checkout@v1`](https://github.com/actions/checkout/tree/v1) support is being dropped in favor of [`actions/checkout@v2`](https://github.com/actions/checkout/releases/tag/v2)
|
||||
|
||||
## [2.3.2] - 2019-12-29
|
||||
|
||||
### Added:
|
||||
|
||||
- `cwd` parameter: lets you set the Current Working Directory
|
||||
|
||||
## [2.3.1] - 2019-12-20
|
||||
### Added:
|
||||
|
||||
### Added:
|
||||
|
||||
- Short tags: from now on, there will be short major tags available (`v2`, `v3`, ...)
|
||||
|
||||
## [2.3.0] - 2019-12-14
|
||||
|
||||
### Changed:
|
||||
|
||||
- TypeScript rewrite: the action will run faster because, unlike with Docker, no build process is needed
|
||||
|
||||
### Added:
|
||||
|
||||
- OS support: the action can now run in non-Linux environments too
|
||||
|
||||
## [2.2.0] - 2019-12-14
|
||||
|
||||
### Added:
|
||||
|
||||
- The action can automatically fetch the commit author to use
|
||||
- You can manually provide the author using the `author_name` and `author_email` parameters
|
||||
|
||||
## [2.1.1] - 2019-12-07
|
||||
|
||||
### Fixed:
|
||||
|
||||
- The action can now be used multiple times in the same workflow
|
||||
|
||||
## [2.1.0] - 2019-09-19
|
||||
|
||||
### Added:
|
||||
|
||||
- `force` parameter: uses `--force` when running `git add`
|
||||
|
||||
## [2.0.0] - 2019-09-18
|
||||
|
||||
### Changed:
|
||||
|
||||
- **[BREAKING]** The action now uses a `find` command
|
||||
|
||||
## [1.0.0] - 2019-09-17
|
||||
|
||||
First release
|
||||
|
||||
#
|
||||
[Unreleased]: https://github.com/EndBug/add-and-commit/compare/v5.1.0...HEAD
|
||||
|
||||
[unreleased]: https://github.com/EndBug/add-and-commit/compare/v7.2.1...HEAD
|
||||
[1.0.0]: https://github.com/EndBug/add-and-commit/tree/v1.0.0
|
||||
[2.0.0]: https://github.com/EndBug/add-and-commit/compare/v1.0.0...v2.0.0
|
||||
[2.1.0]: https://github.com/EndBug/add-and-commit/compare/v2.0.0...v2.1.0
|
||||
@@ -134,3 +270,16 @@ First release
|
||||
[4.4.0]: https://github.com/EndBug/add-and-commit/compare/v4.3.0...v4.4.0
|
||||
[5.0.0]: https://github.com/EndBug/add-and-commit/compare/v4.4.0...v5.0.0
|
||||
[5.1.0]: https://github.com/EndBug/add-and-commit/compare/v5.0.0...v5.1.0
|
||||
[5.1.1]: https://github.com/EndBug/add-and-commit/compare/v5.1.0...v5.1.1
|
||||
[5.1.2]: https://github.com/EndBug/add-and-commit/compare/v5.1.1...v5.1.2
|
||||
[5.2.0]: https://github.com/EndBug/add-and-commit/compare/v5.1.2...v5.2.0
|
||||
[5.3.0]: https://github.com/EndBug/add-and-commit/compare/v5.2.0...v5.3.0
|
||||
[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
|
||||
|
||||
203
README.md
203
README.md
@@ -1,6 +1,7 @@
|
||||
# Add & Commit
|
||||
<a href="https://github.com/search?o=desc&q=EndBug%2Fadd-and-commit+path%3A.github%2Fworkflows+language%3AYAML&s=&type=Code" target="_blank" title="Public workflows that use this action."><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fapi-git-master.endbug.vercel.app%2Fapi%2Fgithub-actions%2Fused-by%3Faction%3DEndBug%2Fadd-and-commit%26badge%3Dtrue" alt="Public workflows that use this action."></a>
|
||||
[](#contributors-)
|
||||
|
||||
[](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....
|
||||
|
||||
@@ -12,18 +13,18 @@ This action lets you choose the path that you want to use when adding & committi
|
||||
Add a step like this to your workflow:
|
||||
|
||||
```yaml
|
||||
- uses: EndBug/add-and-commit@v5 # You can change this to use a specific version
|
||||
- uses: EndBug/add-and-commit@v7 # 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
|
||||
# Default: depends on the default_author input
|
||||
author_name: Your 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
|
||||
# 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
|
||||
@@ -34,13 +35,28 @@ Add a step like this to your workflow:
|
||||
# Default: '.'
|
||||
cwd: './path/to/the/repo'
|
||||
|
||||
# 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:
|
||||
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. Use NO-PULL to avoid the action pulling at all.
|
||||
# Default: '--no-rebase'
|
||||
pull_strategy: 'NO-PULL or --no-rebase or --no-ff or --rebase'
|
||||
|
||||
# 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
|
||||
push: false
|
||||
|
||||
# The arguments for the `git rm` command (see the paragraph below for more info)
|
||||
# Default: ''
|
||||
remove: "./dir/old_file.js"
|
||||
remove: './dir/old_file.js'
|
||||
|
||||
# Whether to use the --signoff option on `git commit` (only `true` and `false` are accepted)
|
||||
# Default: false
|
||||
@@ -48,68 +64,119 @@ Add a step like this to your workflow:
|
||||
|
||||
# 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"
|
||||
|
||||
env:
|
||||
# This is necessary in order to push a commit to the repo
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Leave this line unchanged
|
||||
tag: 'v1.0.0 --force'
|
||||
```
|
||||
|
||||
### Environment variables:
|
||||
### Git arguments
|
||||
|
||||
The only `env` variable required is the token for the action to run: GitHub generates one automatically, but you need to pass it through `env` to make it available to actions. You can find more about `GITHUB_TOKEN` [here](https://help.github.com/en/articles/virtual-environments-for-github-actions#github_token-secret).
|
||||
That said, you can just copy the example line and not worry about it. If you do want to use a different token you can pass that in, but I wouldn't see any possible advantage in doing so.
|
||||
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:
|
||||
|
||||
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:
|
||||
|
||||
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:
|
||||
|
||||
- `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.
|
||||
- any other string:
|
||||
The action will use your string as the arguments for the `git push` command. Please note that nothing is used other than your arguments, and the command will result in `git push ${push input}` (no remote, no branch, no `--set-upstream`, you have to include them yourself).
|
||||
|
||||
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:
|
||||
|
||||
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).
|
||||
|
||||
### 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.
|
||||
|
||||
### 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)
|
||||
|
||||
### Outputs:
|
||||
|
||||
The action provides these outputs:
|
||||
|
||||
- `committed`: whether the action has created a commit (`'true'` or `'false'`)
|
||||
- `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:
|
||||
|
||||
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@v7.0.0
|
||||
with:
|
||||
default_author: github_actions
|
||||
```
|
||||
|
||||
|
||||
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:
|
||||
|
||||
```yaml
|
||||
name: Lint source code
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
jobs:
|
||||
run:
|
||||
name: Lint with ESLint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v2
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 12.x
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 12.x
|
||||
|
||||
- name: Update source code
|
||||
run: eslint "src/**" --fix
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
|
||||
- name: Commit changes
|
||||
uses: EndBug/add-and-commit@v5
|
||||
with:
|
||||
author_name: Your Name
|
||||
author_email: mail@example.com
|
||||
message: "Your commit message"
|
||||
add: "*.js"
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Update source code
|
||||
run: eslint "src/**" --fix
|
||||
|
||||
- name: Commit changes
|
||||
uses: EndBug/add-and-commit@v7
|
||||
with:
|
||||
author_name: Your Name
|
||||
author_email: mail@example.com
|
||||
message: 'Your commit message'
|
||||
add: '*.js'
|
||||
```
|
||||
|
||||
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.
|
||||
@@ -118,7 +185,7 @@ If you need to run the action on a repository that is not located in [`$GITHUB_W
|
||||
name: Use a different repository directory
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
jobs:
|
||||
run:
|
||||
name: Add a text file
|
||||
runs-on: ubuntu-latest
|
||||
@@ -127,19 +194,17 @@ jobs:
|
||||
# If you need to, you can check out your repo to a different location
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
path: "./pathToRepo/"
|
||||
path: './pathToRepo/'
|
||||
|
||||
# You can make whatever type of change to the repo...
|
||||
- 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@v5
|
||||
- uses: EndBug/add-and-commit@v7
|
||||
with:
|
||||
message: "Add the very useful text file"
|
||||
add: "*.txt --force"
|
||||
cwd: "./pathToRepo/"
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
message: 'Add the very useful text file'
|
||||
add: '*.txt --force'
|
||||
cwd: './pathToRepo/'
|
||||
```
|
||||
|
||||
## Contributors ✨
|
||||
@@ -151,30 +216,44 @@ 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></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>
|
||||
</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!
|
||||
|
||||
26
action.yml
26
action.yml
@@ -19,9 +19,21 @@ inputs:
|
||||
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. Use NO-PULL to avoid the action pulling at all.
|
||||
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
|
||||
default: 'true'
|
||||
remove:
|
||||
description: Arguments for the git rm command
|
||||
required: false
|
||||
@@ -31,6 +43,20 @@ inputs:
|
||||
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
|
||||
|
||||
# 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.
|
||||
pushed:
|
||||
description: Whether the action has pushed to the remote.
|
||||
tagged:
|
||||
description: Whether the action has created a tag.
|
||||
|
||||
runs:
|
||||
using: node12
|
||||
|
||||
10
lib/index.js
generated
10
lib/index.js
generated
File diff suppressed because one or more lines are too long
5307
package-lock.json
generated
5307
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
40
package.json
40
package.json
@@ -1,14 +1,16 @@
|
||||
{
|
||||
"name": "add-and-commit",
|
||||
"version": "5.1.0",
|
||||
"version": "7.2.1",
|
||||
"private": true,
|
||||
"description": "Add & commit files from a path directly from GitHub Actions",
|
||||
"main": "lib/index.js",
|
||||
"scripts": {
|
||||
"build": "npm run inputs && ncc build src/main.ts --minify --out lib",
|
||||
"build": "ncc build src/main.ts --minify --out lib",
|
||||
"watch": "ncc build src/main.ts --watch --out lib",
|
||||
"all-contributors-badge": "ts-node scripts/all-contributors-badge",
|
||||
"changelog": "ts-node scripts/changelog.ts",
|
||||
"inputs": "ts-node scripts/inputs.ts",
|
||||
"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"
|
||||
},
|
||||
"repository": {
|
||||
@@ -29,20 +31,26 @@
|
||||
},
|
||||
"homepage": "https://github.com/EndBug/add-and-commit#readme",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.6",
|
||||
"axios": "^0.19.2",
|
||||
"simple-git": "^2.19.0"
|
||||
"@actions/core": "^1.2.7",
|
||||
"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": "^4.0.1",
|
||||
"@types/node": "^12.12.54",
|
||||
"@types/yamljs": "^0.2.31",
|
||||
"@typescript-eslint/eslint-plugin": "^2.34.0",
|
||||
"@typescript-eslint/parser": "^2.34.0",
|
||||
"@vercel/ncc": "^0.23.0",
|
||||
"all-contributors-cli": "^6.17.2",
|
||||
"eslint": "^6.8.0",
|
||||
"ts-node": "^8.10.2",
|
||||
"typescript": "^4.0.2",
|
||||
"@typescript-eslint/eslint-plugin": "^4.23.0",
|
||||
"@typescript-eslint/parser": "^4.23.0",
|
||||
"@vercel/ncc": "^0.28.3",
|
||||
"all-contributors-cli": "^6.20.0",
|
||||
"eslint": "^7.26.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-prettier": "^3.4.0",
|
||||
"husky": "^6.0.0",
|
||||
"prettier": "^2.3.0",
|
||||
"ts-node": "^9.1.1",
|
||||
"typescript": "^4.2.4",
|
||||
"yamljs": "^0.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
import * as fs from 'fs'
|
||||
import { resolve } from 'path'
|
||||
|
||||
function path(...segments: string[]) {
|
||||
return resolve(__dirname, '..', ...segments)
|
||||
}
|
||||
|
||||
const README = fs.readFileSync(path('README.md'), { encoding: 'utf8' }),
|
||||
{ contributors } = JSON.parse(fs.readFileSync(path('.all-contributorsrc'), { encoding: 'utf8' }))
|
||||
if (!(contributors instanceof Array)) throw new Error('Invalid config file')
|
||||
|
||||
const updatedREADME = README
|
||||
.split('\n')
|
||||
.map(line =>
|
||||
line.startsWith('[
|
||||
? `[](#contributors-)`
|
||||
: line
|
||||
).join('\n')
|
||||
|
||||
fs.writeFileSync(path('README.md'), updatedREADME)
|
||||
@@ -2,7 +2,7 @@ import fs from 'fs'
|
||||
import path from 'path'
|
||||
|
||||
const currentVersion = require('../package.json').version
|
||||
if (!currentVersion) throw new Error('Cant\'t detect library version.')
|
||||
if (!currentVersion) throw new Error("Cant't detect library version.")
|
||||
|
||||
const changelogPath = path.resolve(__dirname, '../CHANGELOG.md')
|
||||
const changelog = fs.readFileSync(changelogPath, { encoding: 'utf-8' })
|
||||
@@ -12,7 +12,8 @@ let futureChangelog = ''
|
||||
|
||||
// Add version section
|
||||
let arr = changelog.split('## [Unreleased]')
|
||||
arr[1] = `
|
||||
arr[1] =
|
||||
`
|
||||
|
||||
## [${currentVersion}] - ${new Date().toISOString().slice(0, 10)}
|
||||
### Removed:
|
||||
@@ -26,15 +27,15 @@ arr[1] = `
|
||||
futureChangelog = arr.join('## [Unreleased]')
|
||||
|
||||
// Update footer
|
||||
arr = futureChangelog
|
||||
.split('\n')
|
||||
.map(line => line.startsWith('[Unreleased]')
|
||||
? `[Unreleased]: https://github.com/EndBug/add-and-commit/compare/v${currentVersion}...HEAD`
|
||||
: line)
|
||||
arr = futureChangelog.split('\n').map((line) =>
|
||||
line.startsWith('[unreleased]') // The link ref is lowercase because of prettier
|
||||
? `[unreleased]: https://github.com/EndBug/add-and-commit/compare/v${currentVersion}...HEAD`
|
||||
: line
|
||||
)
|
||||
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
const lastVersion = ([...arr].reverse()[1]?.match(/\[([^\][]*)]/) || [])[0].replace(/[\[\]']+/g, '')
|
||||
if (!lastVersion) throw new Error('Can\'t find last version in changelog.')
|
||||
const lastVersion = ([...arr].reverse()[1]?.match(/\[([^\][]*)]/) ||
|
||||
[])[0].replace(/[\[\]']+/g, '') // eslint-disable-line no-useless-escape
|
||||
if (!lastVersion) throw new Error("Can't find last version in changelog.")
|
||||
|
||||
const lastLine = `[${currentVersion}]: https://github.com/EndBug/add-and-commit/compare/v${lastVersion}...v${currentVersion}`
|
||||
if (arr[arr.length - 1] === '') arr[arr.length - 1] = lastLine
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
import YAML from 'yamljs'
|
||||
import fs from 'fs'
|
||||
|
||||
const actionManifest = YAML.load('action.yml'),
|
||||
inputs = Object.keys(actionManifest?.inputs || {})
|
||||
|
||||
fs.writeFileSync('src/inputs.ts', `
|
||||
// WARNING: this file is auto-generated by scripts/inputs.ts (npm run inputs), any manual edit will be overwritten.
|
||||
|
||||
export type Input = ${inputs.map(s => `'${s}'`).join(' | ')}
|
||||
`.trimLeft())
|
||||
@@ -1,3 +0,0 @@
|
||||
// WARNING: this file is auto-generated by scripts/inputs.ts (npm run inputs), any manual edit will be overwritten.
|
||||
|
||||
export type Input = 'add' | 'author_name' | 'author_email' | 'branch' | 'cwd' | 'message' | 'remove' | 'signoff' | 'tag'
|
||||
510
src/main.ts
510
src/main.ts
@@ -1,99 +1,184 @@
|
||||
import { info, setFailed, getInput as getInputCore, warning, debug, startGroup, endGroup, error } from '@actions/core'
|
||||
import axios from 'axios'
|
||||
import * as core from '@actions/core'
|
||||
import path from 'path'
|
||||
import simpleGit, { Response } from 'simple-git'
|
||||
|
||||
import { Input } from './inputs'
|
||||
import YAML from 'js-yaml'
|
||||
import {
|
||||
getInput,
|
||||
getUserInfo,
|
||||
Input,
|
||||
log,
|
||||
matchGitArgs,
|
||||
outputs,
|
||||
parseBool,
|
||||
readJSON,
|
||||
setOutput
|
||||
} from './util'
|
||||
|
||||
const baseDir = path.join(process.cwd(), getInput('cwd') || '')
|
||||
const git = simpleGit({ baseDir })
|
||||
console.log(`Running in ${baseDir}`);
|
||||
core.info(`Running in ${baseDir}`)
|
||||
;(async () => {
|
||||
await checkInputs().catch(core.setFailed)
|
||||
|
||||
(async () => {
|
||||
await checkInputs().catch(setFailed)
|
||||
|
||||
startGroup('Internal logs')
|
||||
info('> Staging files...')
|
||||
core.startGroup('Internal logs')
|
||||
core.info('> Staging files...')
|
||||
|
||||
if (getInput('add')) {
|
||||
info('> Adding files...')
|
||||
core.info('> Adding files...')
|
||||
await add()
|
||||
} else info('> No files to add.')
|
||||
} else core.info('> No files to add.')
|
||||
|
||||
if (getInput('remove')) {
|
||||
info('> Removing files...')
|
||||
core.info('> Removing files...')
|
||||
await remove()
|
||||
} else info('> No files to remove.')
|
||||
} 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.`)
|
||||
core.info(`> Found ${changedFiles} changed files.`)
|
||||
|
||||
await git
|
||||
.addConfig('user.email', getInput('author_email'), undefined, log)
|
||||
.addConfig('user.name', getInput('author_name'), undefined, log)
|
||||
debug('> Current git config\n' + JSON.stringify((await git.listConfig()).all, null, 2))
|
||||
core.debug(
|
||||
'> Current git config\n' +
|
||||
JSON.stringify((await git.listConfig()).all, null, 2)
|
||||
)
|
||||
|
||||
await git.fetch(['--tags', '--force'], log)
|
||||
|
||||
info('> Switching/creating branch...')
|
||||
core.info('> Switching/creating branch...')
|
||||
await git
|
||||
.checkout(getInput('branch'), undefined, log)
|
||||
.catch(() => git.checkoutLocalBranch(getInput('branch'), log))
|
||||
|
||||
info('> Pulling from remote...')
|
||||
await git
|
||||
.fetch(undefined, log)
|
||||
.pull(undefined, undefined, undefined, log)
|
||||
if (getInput('pull_strategy') == 'NO-PULL')
|
||||
core.info('> Not pulling from repo.')
|
||||
else {
|
||||
core.info('> Pulling from remote...')
|
||||
await git.fetch(undefined, log).pull(
|
||||
undefined,
|
||||
undefined,
|
||||
{
|
||||
[getInput('pull_strategy')]: null
|
||||
},
|
||||
log
|
||||
)
|
||||
}
|
||||
|
||||
info('> Re-staging files...')
|
||||
core.info('> Re-staging files...')
|
||||
if (getInput('add')) await add({ ignoreErrors: true })
|
||||
if (getInput('remove')) await remove({ ignoreErrors: true })
|
||||
|
||||
info('> Creating commit...')
|
||||
await git.commit(getInput('message'), undefined, {
|
||||
'--author': `"${getInput('author_name')} <${getInput('author_email')}>"`,
|
||||
...(getInput('signoff') ? {
|
||||
'--signoff': null
|
||||
} : {})
|
||||
}, log)
|
||||
core.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)
|
||||
}
|
||||
)
|
||||
|
||||
if (getInput('tag')) {
|
||||
info('> Tagging commit...')
|
||||
await git.tag(getInput('tag').split(' '), log)
|
||||
} else info('> No tag info provided.')
|
||||
core.info('> Tagging commit...')
|
||||
await git
|
||||
.tag(matchGitArgs(getInput('tag')), (err, data?) => {
|
||||
if (data) setOutput('tagged', 'true')
|
||||
return log(err, data)
|
||||
})
|
||||
.then((data) => {
|
||||
setOutput('tagged', 'true')
|
||||
return log(null, data)
|
||||
})
|
||||
.catch((err) => core.setFailed(err))
|
||||
} else core.info('> No tag info provided.')
|
||||
|
||||
info('> Pushing commit to repo...')
|
||||
await git.push('origin', getInput('branch'), { '--set-upstream': null }, log)
|
||||
const pushOption = parseBool(getInput('push')) ?? getInput('push')
|
||||
if (pushOption) {
|
||||
// If the options is `true | string`...
|
||||
core.info('> Pushing commit to repo...')
|
||||
|
||||
if (getInput('tag')) {
|
||||
info('> Pushing tags to repo...')
|
||||
await git.pushTags('origin', (e, d?) => log(undefined, e || d)).catch(() => {
|
||||
info('> Tag push failed: deleting remote tag and re-pushing...')
|
||||
return git.push(undefined, undefined, {
|
||||
'--delete': null,
|
||||
'origin': null,
|
||||
[getInput('tag').split(' ').filter(w => !w.startsWith('-'))[0]]: null
|
||||
}, log)
|
||||
.pushTags('origin', log)
|
||||
})
|
||||
} else info('> No tags to push.')
|
||||
if (pushOption === true) {
|
||||
core.debug(
|
||||
`Running: git push origin ${getInput('branch')} --set-upstream`
|
||||
)
|
||||
await git.push(
|
||||
'origin',
|
||||
getInput('branch'),
|
||||
{ '--set-upstream': null },
|
||||
(err, data?) => {
|
||||
if (data) setOutput('pushed', 'true')
|
||||
return log(err, data)
|
||||
}
|
||||
)
|
||||
} else {
|
||||
core.debug(`Running: git push ${pushOption}`)
|
||||
await git.push(
|
||||
undefined,
|
||||
undefined,
|
||||
matchGitArgs(pushOption),
|
||||
(err, data?) => {
|
||||
if (data) setOutput('pushed', 'true')
|
||||
return log(err, data)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
endGroup()
|
||||
info('> Task completed.')
|
||||
if (getInput('tag')) {
|
||||
core.info('> Pushing tags to repo...')
|
||||
await git
|
||||
.pushTags('origin', undefined, (e, d?) => log(undefined, e || d))
|
||||
.catch(() => {
|
||||
core.info(
|
||||
'> Tag push failed: deleting remote tag and re-pushing...'
|
||||
)
|
||||
return git
|
||||
.push(
|
||||
undefined,
|
||||
undefined,
|
||||
{
|
||||
'--delete': null,
|
||||
origin: null,
|
||||
[matchGitArgs(getInput('tag')).filter(
|
||||
(w) => !w.startsWith('-')
|
||||
)[0]]: null
|
||||
},
|
||||
log
|
||||
)
|
||||
.pushTags('origin', undefined, log)
|
||||
})
|
||||
} else core.info('> No tags to push.')
|
||||
} else core.info('> Not pushing anything.')
|
||||
|
||||
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.')
|
||||
}
|
||||
})().catch(e => {
|
||||
endGroup()
|
||||
setFailed(e)
|
||||
})
|
||||
})()
|
||||
.then(logOutputs)
|
||||
.catch((e) => {
|
||||
core.endGroup()
|
||||
logOutputs()
|
||||
core.setFailed(e)
|
||||
})
|
||||
|
||||
async function checkInputs() {
|
||||
function setInput(input: Input, value: string | undefined) {
|
||||
if (value) return process.env[`INPUT_${input.toUpperCase()}`] = value
|
||||
if (value) return (process.env[`INPUT_${input.toUpperCase()}`] = value)
|
||||
else return delete process.env[`INPUT_${input.toUpperCase()}`]
|
||||
}
|
||||
function setDefault(input: Input, value: string) {
|
||||
@@ -102,113 +187,270 @@ async function checkInputs() {
|
||||
}
|
||||
|
||||
const eventPath = process.env.GITHUB_EVENT_PATH,
|
||||
event = eventPath && require(eventPath),
|
||||
token = process.env.GITHUB_TOKEN,
|
||||
isPR = process.env.GITHUB_EVENT_NAME?.includes('pull_request'),
|
||||
sha = (event?.pull_request?.head?.sha || process.env.GITHUB_SHA) as string,
|
||||
defaultBranch = isPR
|
||||
? event?.pull_request?.head?.ref as string
|
||||
: process.env.GITHUB_REF?.substring(11)
|
||||
event = eventPath && readJSON(eventPath)
|
||||
|
||||
// #region GITHUB_TOKEN
|
||||
if (!token) warning('The GITHUB_TOKEN env variable is missing: the action may not work as expected.')
|
||||
// #endregion
|
||||
const isPR = process.env.GITHUB_EVENT_NAME?.includes('pull_request'),
|
||||
defaultBranch = isPR
|
||||
? (event?.pull_request?.head?.ref as string)
|
||||
: process.env.GITHUB_REF?.substring(11)
|
||||
|
||||
// #region add, remove
|
||||
if (!getInput('add') && !getInput('remove'))
|
||||
throw new Error('Both \'add\' and \'remove\' are empty, the action has nothing to do.')
|
||||
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(
|
||||
', '
|
||||
)}`
|
||||
)
|
||||
|
||||
// #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...')
|
||||
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
|
||||
}
|
||||
|
||||
// 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
|
||||
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."
|
||||
)
|
||||
|
||||
author = commit?.commit?.author
|
||||
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)'
|
||||
)
|
||||
}
|
||||
|
||||
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.`)
|
||||
setDefault('author_name', name)
|
||||
setDefault('author_email', email)
|
||||
core.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.`)
|
||||
setDefault(
|
||||
'message',
|
||||
`Commit from GitHub Actions (${process.env.GITHUB_WORKFLOW})`
|
||||
)
|
||||
core.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.`)
|
||||
if (isPR)
|
||||
core.info(`> Running for a PR, the action will use '${branch}' as ref.`)
|
||||
// #endregion
|
||||
|
||||
// #region signoff
|
||||
if (getInput('signoff')) try {
|
||||
const parsed = JSON.parse(getInput('signoff'))
|
||||
if (typeof parsed == 'boolean' && !parsed)
|
||||
setInput('signoff', undefined)
|
||||
debug(`Current signoff option: ${getInput('signoff')} (${typeof getInput('signoff')})`)
|
||||
} catch {
|
||||
throw new Error(`"${getInput('signoff')}" is not a valid value for the 'signoff' input: only "true" and "false" are allowed.`)
|
||||
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)
|
||||
|
||||
core.debug(
|
||||
`Current signoff option: ${getInput('signoff')} (${typeof getInput(
|
||||
'signoff'
|
||||
)})`
|
||||
)
|
||||
}
|
||||
// #endregion
|
||||
|
||||
// #region pull_strategy
|
||||
if (getInput('pull_strategy') == 'NO-PULL')
|
||||
core.debug("NO-PULL found: won't pull from remote.")
|
||||
// #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'))
|
||||
|
||||
core.debug(
|
||||
`Current push option: '${getInput('push')}' (parsed as ${typeof parsed})`
|
||||
)
|
||||
}
|
||||
// #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'
|
||||
)
|
||||
}
|
||||
|
||||
function getInput(name: Input) {
|
||||
return getInputCore(name)
|
||||
async function add({ logWarning = true, ignoreErrors = false } = {}): Promise<
|
||||
(void | Response<void>)[]
|
||||
> {
|
||||
const input = getInput('add')
|
||||
if (!input) return []
|
||||
|
||||
const parsed = parseInputArray(input)
|
||||
const res: (void | Response<void>)[] = []
|
||||
|
||||
for (const args of parsed) {
|
||||
res.push(
|
||||
// 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(matchGitArgs(args), (err: any, data?: any) =>
|
||||
log(ignoreErrors ? null : err, data)
|
||||
)
|
||||
.catch((e: Error) => {
|
||||
if (ignoreErrors) return
|
||||
if (
|
||||
e.message.includes('fatal: pathspec') &&
|
||||
e.message.includes('did not match any files') &&
|
||||
logWarning
|
||||
)
|
||||
core.warning(
|
||||
`Add command did not match any file:\n git add ${args}`
|
||||
)
|
||||
else throw e
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
function log(err: any | Error, data?: any) {
|
||||
if (data) console.log(data)
|
||||
if (err) error(err)
|
||||
async function remove({
|
||||
logWarning = true,
|
||||
ignoreErrors = false
|
||||
} = {}): Promise<(void | Response<void>)[]> {
|
||||
const input = getInput('remove')
|
||||
if (!input) return []
|
||||
|
||||
const parsed = parseInputArray(input)
|
||||
const res: (void | Response<void>)[] = []
|
||||
|
||||
for (const args of parsed) {
|
||||
res.push(
|
||||
// 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(matchGitArgs(args), (e: any, d?: any) =>
|
||||
log(ignoreErrors ? null : e, d)
|
||||
)
|
||||
.catch((e: Error) => {
|
||||
if (ignoreErrors) return
|
||||
if (
|
||||
e.message.includes('fatal: pathspec') &&
|
||||
e.message.includes('did not match any files')
|
||||
)
|
||||
logWarning &&
|
||||
core.warning(
|
||||
`Remove command did not match any file:\n git rm ${args}`
|
||||
)
|
||||
else throw e
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
function add({ logWarning = true, ignoreErrors = false } = {}): Promise<void | Response<void>> | void {
|
||||
if (getInput('add'))
|
||||
return git.add(getInput('add').split(' '), (e: any, d?: any) => log(ignoreErrors ? null : e, d)).catch((e: Error) => {
|
||||
if (ignoreErrors) return
|
||||
if (e.message.includes('fatal: pathspec') && e.message.includes('did not match any files'))
|
||||
logWarning && warning('Add command did not match any file.')
|
||||
else throw e
|
||||
})
|
||||
/**
|
||||
* 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')
|
||||
) {
|
||||
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]
|
||||
}
|
||||
|
||||
function remove({ logWarning = true, ignoreErrors = false } = {}): Promise<void | Response<void>> | void {
|
||||
if (getInput('remove'))
|
||||
return git.rm(getInput('remove').split(' '), (e: any, d?: any) => log(ignoreErrors ? null : e, d)).catch((e: Error) => {
|
||||
if (ignoreErrors) return
|
||||
if (e.message.includes('fatal: pathspec') && e.message.includes('did not match any files'))
|
||||
logWarning && warning('Remove command did not match any file.')
|
||||
else throw e
|
||||
})
|
||||
function logOutputs() {
|
||||
core.startGroup('Outputs')
|
||||
for (const key in outputs) {
|
||||
core.info(`${key}: ${outputs[key]}`)
|
||||
}
|
||||
core.endGroup()
|
||||
}
|
||||
|
||||
124
src/util.ts
Normal file
124
src/util.ts
Normal file
@@ -0,0 +1,124 @@
|
||||
import { parseArgsStringToArgv } from 'string-argv'
|
||||
import * as core from '@actions/core'
|
||||
import { Toolkit } from 'actions-toolkit'
|
||||
import fs from 'fs'
|
||||
|
||||
export type Input =
|
||||
| 'add'
|
||||
| 'author_name'
|
||||
| 'author_email'
|
||||
| 'branch'
|
||||
| 'cwd'
|
||||
| 'default_author'
|
||||
| 'message'
|
||||
| 'pull_strategy'
|
||||
| 'push'
|
||||
| 'remove'
|
||||
| 'signoff'
|
||||
| 'tag'
|
||||
| 'github_token'
|
||||
|
||||
export type Output = 'committed' | 'pushed' | 'tagged'
|
||||
|
||||
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: Record<Output, 'true' | 'false'> = {
|
||||
committed: 'false',
|
||||
pushed: 'false',
|
||||
tagged: 'false'
|
||||
}
|
||||
|
||||
export function getInput(name: Input) {
|
||||
return tools.inputs[name] || ''
|
||||
}
|
||||
|
||||
export async function getUserInfo(username?: string) {
|
||||
if (!username) return undefined
|
||||
|
||||
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) {
|
||||
if (data) console.log(data)
|
||||
if (err) core.error(err)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 parseBool(value: any) {
|
||||
try {
|
||||
const parsed = JSON.parse(value)
|
||||
if (typeof parsed == 'boolean') return parsed
|
||||
} catch {}
|
||||
}
|
||||
|
||||
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}`
|
||||
}
|
||||
}
|
||||
|
||||
export function setOutput<T extends Output>(name: T, value: typeof outputs[T]) {
|
||||
core.debug(`Setting output: ${name}=${value}`)
|
||||
outputs[name] = value
|
||||
core.setOutput(name, value)
|
||||
}
|
||||
|
||||
// Setup default output values
|
||||
Object.entries(outputs).forEach(([name, value]) => core.setOutput(name, value))
|
||||
@@ -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