Skip to content

Commit

Permalink
Add compiled action
Browse files Browse the repository at this point in the history
  • Loading branch information
igorjs committed Mar 27, 2022
1 parent 6880fa3 commit af8e650
Show file tree
Hide file tree
Showing 17 changed files with 8,508 additions and 312 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
19 changes: 19 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"env": {
"commonjs": true,
"es6": true,
"jest": true,
"node": true
},
"extends": "eslint:recommended",
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2021,
"sourceType": "module"
},
"rules": {
}
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ist/** -diff linguist-generated=true
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2

updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily

- package-ecosystem: npm
directory: /
schedule:
interval: daily
51 changes: 51 additions & 0 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# `dist/index.js` is a special file in Actions.
# When you reference an action with `uses:` in a workflow,
# `index.js` is the code that will run.
# For our project, we generate this file through a build process from other source files.
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
name: Check dist/

on:
push:
branches:
- main
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
workflow_dispatch:

jobs:
check-dist:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set Node.js 12.x
uses: actions/[email protected]
with:
node-version: 12.x

- name: Install dependencies
run: npm ci

- name: Rebuild the dist/ directory
run: npm run prepare

- name: Compare the expected and actual dist/ directories
run: |
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff
exit 1
fi
id: diff

# If index.js was different than expected, upload the expected version as an artifact
- uses: actions/upload-artifact@v2
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with:
name: dist
path: dist/
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Unit tests

on:
pull_request:
push:
branches:
- main
- 'releases/*'

jobs:
# unit tests
units:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm ci
- run: npm test

# test action works running from the graph
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ./
with:
milliseconds: 1000
20 changes: 20 additions & 0 deletions .github/workflows/trigger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Clean workflows

on:
workflow_dispatch:
inputs:
days_old:
description: "The amount of days old to delete"
default: "7"
required: false

jobs:
clean-wf:
runs-on: ubuntu-latest
steps:
- uses: igorjs/github-clean-workflow-action@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
days_old: ${{ github.event.inputs.days_old }}
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @actions/actions-runtime
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 igor.js

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Clean Workflow Action

Clean workflow run logs based on configuration

## Usage

### Parameters
- token: The token to use to access the GitHub API (required)

- owner: The owner of the repository (required)

- repo: The name of the repository (required)

- days_old: The amount of days old to delete (default: '7')

### Outputs

- result: The number of workflows deleted

### Example

```yaml
uses: igorjs/github-clean-workflow-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
days_old: '7'
```
15 changes: 13 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: 'Clean Workflow Action'

description: 'Clean workflow run logs based on configuration'

inputs:
token:
description: 'The token to use to access the GitHub API'
Expand All @@ -10,6 +12,15 @@ inputs:
repo:
description: 'The name of the repository'
required: true
days_old:
description: 'The amount of days old to delete'
required: false
default: '7'

outputs:
result:
description: 'The number of workflows deleted'

runs:
using: 'node16'
main: 'index.js'
using: 'node12'
main: 'dist/index.js'
8 changes: 8 additions & 0 deletions dist/index.js

Large diffs are not rendered by default.

54 changes: 0 additions & 54 deletions index.js

This file was deleted.

Loading

0 comments on commit af8e650

Please sign in to comment.