Skip to content

Commit

Permalink
Initial
Browse files Browse the repository at this point in the history
  • Loading branch information
lasseborly committed Dec 6, 2021
0 parents commit 85780cb
Show file tree
Hide file tree
Showing 15 changed files with 12,361 additions and 0 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
13 changes: 13 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"env": {
"es2021": true,
"node": true
},
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest"
},
"plugins": ["@typescript-eslint"],
"rules": {}
}
21 changes: 21 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Checks

on: pull_request

jobs:
checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: LouisBrunner/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: BackstopJS visual test
conclusion: failure

- uses: LouisBrunner/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: ESLint
conclusion: failure
39 changes: 39 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Test

on:
# https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#issue_comment
# There does not exist an event specifically for PR comments which means
# we need to have that check further down the action definition.
issue_comment:
types: [created]

jobs:
test:
# This condition is important since you want to prevent all of the steps
# from running as early as possible if the comment isn't in a PR.
if: ${{ github.event.issue.pull_request }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: ./
name: Approve BackstopJS
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
check_name: BackstopJS visual test
approve_comment: backstop-check approve

- uses: ./
name: Approve ESLint
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
check_name: ESLint
approve_comment: eslint-check approve

# There is no step in checks.yml named Cypress which will lead this to fail.
- uses: ./
name: Approve Cypress
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
check_name: Cypress
approve_comment: cypress-check approve
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}
73 changes: 73 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# action-approve-failure

GitHub action that let's you turn failure into success. For a short while.

## Example

Presume you have a couple of jobs that run on pull requests.
(These are merely examples but take a look in `.github/workflows` for closer inspection)

```yaml
name: Checks

on: pull_request

jobs:
checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: LouisBrunner/checks-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: BackstopJS visual test
conclusion: failure

- uses: LouisBrunner/checks-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: ESLint
conclusion: failure
```
These jobs might from time to time need to be forced into success since a failure
might just be a new state.
In comes `action-approve-failure`:

```yaml
name: Approve failure
on:
issue_comment:
types: [created]
jobs:
approve-failure:
# This condition is important since you want to prevent all of the steps
# from running as early as possible if the comment isn't in a PR.
if: ${{ github.event.issue.pull_request }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: reload/[email protected]
name: Approve BackstopJS
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
check_name: BackstopJS visual test
approve_comment: backstop-check approve
- uses: reload/[email protected]
name: Approve ESLint
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
check_name: ESLint
approve_comment: eslint-check approve
```

Now, by simply commenting `backstop-check approve` you can turn that `failure`
into a `success`. The victory is short lived though. Whenever the PR get's
updated and the jobs re-run your override will be lost and you are forced to
yet again determine if this failure is change of state or an actual failure.
14 changes: 14 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: "Approve failure"
description: "Approve any check no matter it's actual conclusion."
inputs:
github_token:
required: true
check_name:
required: true
default: "BackstopJS visual test"
approve_comment:
required: true
default: "backstop-check approve"
runs:
using: "node16"
main: "dist/index.js"
Loading

0 comments on commit 85780cb

Please sign in to comment.