Skip to content

Commit 1cd753a

Browse files
committed
Initial build of action.
Signed-off-by: Chris. Webster <chris@webstech.net>
1 parent e880058 commit 1cd753a

17 files changed

+65012
-1
lines changed

.editorconfig

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# EditorConfig is awesome: http://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines with a newline ending every file
7+
[*]
8+
end_of_line = lf
9+
insert_final_newline = true
10+
11+
# Matches multiple files with brace expansion notation
12+
# Set default charset
13+
[*.ts]
14+
charset = utf-8
15+
indent_style = space
16+
indent_size = 4
17+
trim_trailing_whitespace = true
18+
max_line_length = 120

.eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build/
2+
dist/
3+
node_modules/

.eslintrc.js

+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
export default {
2+
"env": {
3+
"es6": true,
4+
"node": true
5+
},
6+
"ignorePatterns": ["build/", "dist/"],
7+
"extends": [
8+
"plugin:@typescript-eslint/recommended",
9+
"plugin:@typescript-eslint/recommended-requiring-type-checking",
10+
"prettier"
11+
],
12+
"parser": "@typescript-eslint/parser",
13+
"parserOptions": {
14+
"project": "tsconfig.json",
15+
"sourceType": "module"
16+
},
17+
"plugins": [
18+
"anti-trojan-source",
19+
"@typescript-eslint"
20+
],
21+
"rules": {
22+
"@typescript-eslint/array-type": [
23+
"error",
24+
{
25+
"default": "array-simple"
26+
}
27+
],
28+
"@typescript-eslint/consistent-type-assertions": "error",
29+
"@typescript-eslint/dot-notation": "error",
30+
"@typescript-eslint/naming-convention": [
31+
"error",
32+
{
33+
"format": [
34+
"camelCase",
35+
"snake_case"
36+
],
37+
"selector": "variable"
38+
}
39+
],
40+
"@typescript-eslint/no-unused-expressions": "error",
41+
"@typescript-eslint/prefer-for-of": "error",
42+
"@typescript-eslint/prefer-function-type": "error",
43+
"@typescript-eslint/prefer-regexp-exec": "off",
44+
"@typescript-eslint/restrict-template-expressions": "off",
45+
"@typescript-eslint/triple-slash-reference": [
46+
"error",
47+
{
48+
"lib": "always",
49+
"path": "always",
50+
"types": "prefer-import"
51+
}
52+
],
53+
"@typescript-eslint/unified-signatures": "error",
54+
"anti-trojan-source/no-bidi": "error",
55+
"complexity": "off",
56+
"constructor-super": "error",
57+
"eqeqeq": [
58+
"error",
59+
"smart"
60+
],
61+
"guard-for-in": "error",
62+
"id-blacklist": [
63+
"error",
64+
"any",
65+
"Number",
66+
"String",
67+
"string",
68+
"Boolean",
69+
"boolean",
70+
"Undefined",
71+
"undefined"
72+
],
73+
"id-match": "error",
74+
"max-classes-per-file": [
75+
"error",
76+
1
77+
],
78+
"max-len": [
79+
"error",
80+
{
81+
"code": 120
82+
}
83+
],
84+
"new-parens": "error",
85+
"no-bitwise": "error",
86+
"no-caller": "error",
87+
"no-cond-assign": "error",
88+
"no-console": "off",
89+
"no-debugger": "error",
90+
"no-empty": "error",
91+
"no-eval": "error",
92+
"no-fallthrough": "off",
93+
"no-invalid-this": "off",
94+
"no-new-wrappers": "error",
95+
"no-shadow": [
96+
"error",
97+
{
98+
"hoist": "never"
99+
}
100+
],
101+
"no-throw-literal": "error",
102+
"no-undef-init": "error",
103+
"no-underscore-dangle": "error",
104+
"no-unsafe-finally": "error",
105+
"no-unused-labels": "error",
106+
"object-shorthand": "error",
107+
"one-var": [
108+
"error",
109+
"never"
110+
],
111+
"radix": "error",
112+
"semi": "error",
113+
"spaced-comment": [
114+
"error",
115+
"always",
116+
{
117+
"markers": [
118+
"/"
119+
]
120+
}
121+
],
122+
"use-isnan": "error"
123+
}
124+
};

.ghadocs.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"paths": {
3+
"action": "action.yml",
4+
"readme": "README.md"
5+
},
6+
"show_logo": true,
7+
"versioning": {
8+
"enabled": "true",
9+
"override": "",
10+
"prefix": "v",
11+
"branch": "main"
12+
},
13+
"owner": "gitgitgadget",
14+
"repo": "gitgitgadget-action-check-status",
15+
"title_prefix": "gitgitgadget Action: ",
16+
"pretty": true
17+
}

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* eol=lf
2+
*.png -eol -text binary

.github/dependabot.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
version: 2
2+
updates:
3+
# Run monthly with no limits
4+
- package-ecosystem: "npm"
5+
directory: "/"
6+
schedule:
7+
interval: "monthly"
8+
open-pull-requests-limit: 10
9+
10+
updates:
11+
# Run weekly ignoring patches (esp linters)
12+
- package-ecosystem: "npm"
13+
directory: "/"
14+
schedule:
15+
interval: "weekly"
16+
open-pull-requests-limit: 10
17+
ignore:
18+
# For @types packages, ignore all patch updates
19+
- dependency-name: "@types/*"
20+
update-types: ["version-update:semver-patch"]
21+
# For eslint packages, ignore all patch updates
22+
- dependency-name: "eslint"
23+
update-types: ["version-update:semver-patch"]

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build/
2+
node_modules/

.prettierignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist/
2+
build/

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Chris. Webster
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+121-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,121 @@
1-
# check-status
1+
<!-- start title -->
2+
3+
# gitgitgadget Action: check-status
4+
5+
<!-- end title -->
6+
<!-- start description -->
7+
8+
This is a GitHub action to perform various scheduled actions with projects using gitgitgadget to submit changes. It is used as a scheduled action running in a separate repo or the repo it is acting upon. The use case is for repos that will not allow complex GitHub actions in the codebase when the GitHub repo is a clone that is used to submit updates to a non-GitHub maintained repo.
9+
10+
<!-- end description -->
11+
<!-- start contents -->
12+
<!-- end contents -->
13+
14+
## Usage
15+
16+
<!-- start usage -->
17+
18+
```yaml
19+
- uses: gitgitgadget/gitgitgadget-action-check-status@v0.5.0
20+
with:
21+
# The action to be performed. It must be one of the following: "update-open-prs",
22+
# "update-commit-mappings", "handle-open-prs", "handle-new-mails".
23+
action: ""
24+
25+
# Repository owner.
26+
repo-owner: ""
27+
28+
# Repository name.
29+
repo-name: ""
30+
31+
# A repo scoped GitHub Personal Access Token.
32+
token: ""
33+
34+
# The location of the repository.
35+
repository-dir: ""
36+
37+
# The location of the repository with gitgitgadget configuration information. This
38+
# would be used in place of the `config` parameter for the `git` repository. This
39+
# is normally the gitgitgadget repo with any needed configuration settings. Most
40+
# users will specify a `config`.
41+
config-repository-dir: ""
42+
43+
# JSON configuration for commands.
44+
config: ""
45+
```
46+
47+
<!-- end usage -->
48+
49+
## Inputs
50+
51+
<!-- start inputs -->
52+
53+
| **Input** | **Description** | **Default** | **Required** |
54+
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------- | ------------ |
55+
| **`action`** | The action to be performed. It must be one of the following: "update-open-prs", "update-commit-mappings", "handle-open-prs", "handle-new-mails". | | **true** |
56+
| **`repo-owner`** | Repository owner. | | **true** |
57+
| **`repo-name`** | Repository name. | | **true** |
58+
| **`token`** | A repo scoped GitHub Personal Access Token. | | **true** |
59+
| **`repository-dir`** | The location of the repository. | | **true** |
60+
| **`config-repository-dir`** | The location of the repository with gitgitgadget configuration information. This would be used in place of the `config` parameter for the `git` repository. This is normally the gitgitgadget repo with any needed configuration settings. Most users will specify a `config`. | | **false** |
61+
| **`config`** | JSON configuration for commands. | | **true** |
62+
63+
<!-- end inputs -->
64+
<!-- start outputs -->
65+
<!-- end outputs -->
66+
<!-- start [.github/ghdocs/examples/] -->
67+
<!-- end [.github/ghdocs/examples/] -->
68+
69+
## Contributing
70+
The current tests are Windows based.
71+
72+
### Using a local `gitgitgadget`
73+
This action is a thin layer that uses [gitgitgadget](https://github.com/gitgitgadget/gitgitgadget)
74+
for most of the processing. If you have local changes to `gitgitgadget` that need to be
75+
tested:
76+
1. In the `gitgitgadget` project run `npm pack` to generate an installable package. By default,
77+
the package will be located in the root directory of the project. This can be changed by
78+
specifying `--pack-destination=` on the command.
79+
2. Change the `package.json` to point to the `tgz` packaage file and run `npm install gitgitgadget`.
80+
81+
### action.yml changes
82+
Changes to `action.yml` require regenerating the `README.md`. This is done using `docker`. If it
83+
is not available it should be installed. The `README.md` is updated using `npm run build:readme`.
84+
**Note**: markup is very limited in the `action.yml`.
85+
86+
### Source Changes
87+
The action is built using `npm run build`. This builds a standalone runnable at `dist/index.js`.
88+
89+
### Testing
90+
The action supports four different checks. The checks and associated npm commands are:
91+
92+
- update-open-prs (test:upr)
93+
- update-commit-mappings (test:ucm)
94+
- handle-open-prs (test:hop)
95+
- handle-new-mails (test:hnm)
96+
97+
A windows command is provided for testing. It requires:
98+
99+
1. A test repo set up to be monitored. A GitHub PAT must already be set as
100+
the INPUT_TOKEN environment variable or indentifed in a `.secret` file in
101+
the repo. The format of the `.secret` file is `INPUT_TOKEN=<pat>`.
102+
2. A config describing the test repo.
103+
3. For testing mail checks, a mail repo must be available with valid email.
104+
105+
The test is run using the command:
106+
107+
```
108+
npm run <test-name> <test-repo-owner> <test-repo-name> <config-location> <email-repo-location>
109+
```
110+
### Make a pull request
111+
First, if there are related `gitgitgadget` changes, that pull request should be done first. A fresh
112+
install, build and test should be done using the unmodified `package.json`.
113+
114+
`npm version` may need to be done based on the level of change. If this is done, make sure the
115+
tags get pushed to GitHub.
116+
117+
The patch series will need to include the `dist/index.js`.
118+
119+
## TODO
120+
A separate action will be developed to rebuild the `dist/index.js` as needed when updates to
121+
`gitgitgadget` have been made.

action.yml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: gitgitgadget-action-check-status
2+
author: webstech
3+
description: >
4+
This is a GitHub action to perform various scheduled actions with projects
5+
using gitgitgadget to submit changes. It is used as a scheduled action
6+
running in a separate repo or the repo it is acting upon. The use case
7+
is for repos that will not allow complex GitHub actions in the codebase
8+
when the GitHub repo is a clone that is used to submit updates to a
9+
non-GitHub maintained repo.
10+
11+
inputs:
12+
action:
13+
description: >
14+
The action to be performed. It must be one of the following:
15+
"update-open-prs",
16+
"update-commit-mappings",
17+
"handle-open-prs",
18+
"handle-new-mails".
19+
required: true
20+
repo-owner:
21+
description: Repository owner.
22+
required: true
23+
repo-name:
24+
description: Repository name.
25+
required: true
26+
token:
27+
description: A repo scoped GitHub Personal Access Token.
28+
required: true
29+
repository-dir:
30+
description: The location of the repository.
31+
required: true
32+
config-repository-dir:
33+
description: The location of the repository with gitgitgadget configuration
34+
information. This would be used in place of the `config` parameter for
35+
the `git` repository. This is normally the gitgitgadget repo with any
36+
needed configuration settings. Most users will specify a `config`.
37+
required: false
38+
config:
39+
description: JSON configuration for commands.
40+
required: true
41+
42+
runs:
43+
using: 'node18'
44+
main: 'dist/index.js'
45+
46+
branding:
47+
icon: 'check'
48+
color: 'gray-dark'

0 commit comments

Comments
 (0)