Skip to content

Commit 04c636a

Browse files
committed
Initial
0 parents  commit 04c636a

23 files changed

Lines changed: 38901 additions & 0 deletions

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist/
2+
lib/
3+
node_modules/

.eslintrc.json

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"plugins": ["jest", "@typescript-eslint"],
3+
"extends": ["plugin:github/es6"],
4+
"parser": "@typescript-eslint/parser",
5+
"parserOptions": {
6+
"ecmaVersion": 9,
7+
"sourceType": "module",
8+
"project": "./tsconfig.json"
9+
},
10+
"rules": {
11+
"eslint-comments/no-use": "off",
12+
"import/no-namespace": "off",
13+
"no-unused-vars": "off",
14+
"@typescript-eslint/no-unused-vars": "error",
15+
"@typescript-eslint/explicit-member-accessibility": [
16+
"error",
17+
{ "accessibility": "no-public" }
18+
],
19+
"@typescript-eslint/no-require-imports": "error",
20+
"@typescript-eslint/array-type": "error",
21+
"@typescript-eslint/await-thenable": "error",
22+
"@typescript-eslint/ban-ts-ignore": "error",
23+
"camelcase": "off",
24+
"@typescript-eslint/camelcase": "error",
25+
"@typescript-eslint/class-name-casing": "error",
26+
"@typescript-eslint/explicit-function-return-type": [
27+
"error",
28+
{ "allowExpressions": true }
29+
],
30+
"@typescript-eslint/func-call-spacing": ["error", "never"],
31+
"@typescript-eslint/generic-type-naming": ["error", "^[A-Z][A-Za-z]*$"],
32+
"@typescript-eslint/no-array-constructor": "error",
33+
"@typescript-eslint/no-empty-interface": "error",
34+
"@typescript-eslint/no-explicit-any": "error",
35+
"@typescript-eslint/no-extraneous-class": "error",
36+
"@typescript-eslint/no-for-in-array": "error",
37+
"@typescript-eslint/no-inferrable-types": "error",
38+
"@typescript-eslint/no-misused-new": "error",
39+
"@typescript-eslint/no-namespace": "error",
40+
"@typescript-eslint/no-non-null-assertion": "warn",
41+
"@typescript-eslint/no-object-literal-type-assertion": "error",
42+
"@typescript-eslint/no-unnecessary-qualifier": "error",
43+
"@typescript-eslint/no-unnecessary-type-assertion": "error",
44+
"@typescript-eslint/no-useless-constructor": "error",
45+
"@typescript-eslint/no-var-requires": "error",
46+
"@typescript-eslint/prefer-for-of": "warn",
47+
"@typescript-eslint/prefer-function-type": "warn",
48+
"@typescript-eslint/prefer-includes": "error",
49+
"@typescript-eslint/prefer-interface": "error",
50+
"@typescript-eslint/prefer-string-starts-ends-with": "error",
51+
"@typescript-eslint/promise-function-async": "error",
52+
"@typescript-eslint/require-array-sort-compare": "error",
53+
"@typescript-eslint/restrict-plus-operands": "error",
54+
"semi": "off",
55+
"@typescript-eslint/semi": ["error", "never"],
56+
"@typescript-eslint/type-annotation-spacing": "error",
57+
"@typescript-eslint/unbound-method": "error"
58+
},
59+
"env": {
60+
"node": true,
61+
"es6": true,
62+
"jest/globals": true
63+
}
64+
}

.github/workflows/test.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: 'build-test'
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- master
7+
- 'releases/*'
8+
9+
jobs:
10+
artifact:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Generate artifact to delete
14+
run: |
15+
echo $(date) > date.txt
16+
- name: Upload artifact
17+
uses: actions/upload-artifact@v1
18+
with:
19+
name: artifact
20+
path: date.txt
21+
build:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v1
25+
- run: |
26+
yarn
27+
yarn run all
28+
test:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v1
32+
- uses: ./
33+
with:
34+
token: ${{ secrets.GITHUB_TOKEN }}
35+
expire-in: '30minutes'

.gitignore

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Dependency directory
2+
node_modules
3+
4+
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
5+
# Logs
6+
logs
7+
*.log
8+
npm-debug.log*
9+
yarn-debug.log*
10+
yarn-error.log*
11+
lerna-debug.log*
12+
13+
# Diagnostic reports (https://nodejs.org/api/report.html)
14+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
15+
16+
# Runtime data
17+
pids
18+
*.pid
19+
*.seed
20+
*.pid.lock
21+
22+
# Directory for instrumented libs generated by jscoverage/JSCover
23+
lib-cov
24+
25+
# Coverage directory used by tools like istanbul
26+
coverage
27+
*.lcov
28+
29+
# nyc test coverage
30+
.nyc_output
31+
32+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
33+
.grunt
34+
35+
# Bower dependency directory (https://bower.io/)
36+
bower_components
37+
38+
# node-waf configuration
39+
.lock-wscript
40+
41+
# Compiled binary addons (https://nodejs.org/api/addons.html)
42+
build/Release
43+
44+
# Dependency directories
45+
jspm_packages/
46+
47+
# TypeScript v1 declaration files
48+
typings/
49+
50+
# TypeScript cache
51+
*.tsbuildinfo
52+
53+
# Optional npm cache directory
54+
.npm
55+
56+
# Optional eslint cache
57+
.eslintcache
58+
59+
# Optional REPL history
60+
.node_repl_history
61+
62+
# Output of 'npm pack'
63+
*.tgz
64+
65+
# Yarn Integrity file
66+
.yarn-integrity
67+
68+
# dotenv environment variables file
69+
.env
70+
.env.test
71+
72+
# parcel-bundler cache (https://parceljs.org/)
73+
.cache
74+
75+
# next.js build output
76+
.next
77+
78+
# nuxt.js build output
79+
.nuxt
80+
81+
# vuepress build output
82+
.vuepress/dist
83+
84+
# Serverless directories
85+
.serverless/
86+
87+
# FuseBox cache
88+
.fusebox/
89+
90+
# DynamoDB Local files
91+
.dynamodb/
92+
93+
# OS metadata
94+
.DS_Store
95+
Thumbs.db
96+
97+
# Ignore built ts files
98+
__tests__/runner/*
99+
lib/**/*

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
12.16.1

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist/
2+
lib/
3+
node_modules/

.prettierrc.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"printWidth": 80,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": false,
6+
"singleQuote": true,
7+
"trailingComma": "none",
8+
"arrowParens": "avoid"
9+
}

LICENSE

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

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Delete artifacts action
2+
3+
Action responsible for deleting old artifacts by setting expire duration.
4+
5+
Hopefuly this is just temporary solution till github implements this functionality natively.
6+
7+
## Inputs
8+
### `expire-in`
9+
**Required** for how long the artifacts should be kept.
10+
Most of the human readable formats are supported `10 minutes`, `1hr 20mins`, `1week`.
11+
Take a look at [parse-duration](https://github.com/jkroso/parse-duration) for more information.
12+
13+
14+
## Outputs
15+
### `deleted-artifacts`
16+
Serialized list of deleted artifacts. Empty `[]` when nothing is deleted
17+
18+
## Usage
19+
20+
Run this action as cron. This won't delete artifacts of running workflows because they
21+
are persisted after workflow completion.
22+
23+
```yaml
24+
name: 'Delete old artifacts'
25+
on:
26+
schedule:
27+
- cron: '0 * * * *' # every hour
28+
29+
jobs:
30+
delete-artifacts:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: kolpav/purge-artifacts-action@v1
34+
with:
35+
token: ${{ secrets.GITHUB_TOKEN }}
36+
expire-in: 7days # Setting this to 0 will delete all artifacts
37+
```
38+
39+
## Contributing
40+
41+
There are few improvements to be made, namely
42+
- More delete strategies (name, size, number of occurences, regex match on name etc..)
43+
- Better test coverage

__mocks__/@actions/core.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const core = jest.genMockFromModule("@actions/core")
2+
3+
core.debug = console.log
4+
5+
module.exports = core

0 commit comments

Comments
 (0)