Skip to content

Commit

Permalink
Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-murray authored Nov 15, 2023
1 parent 84465e3 commit f274e23
Show file tree
Hide file tree
Showing 14 changed files with 32,270 additions and 131 deletions.
13 changes: 13 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "Node.js 18",
"image": "ghcr.io/octodemo/development-containers/javascript:base-20230923",
"customizations": {
"vscode": {
"extensions": [
"mikestead.dotenv",
"GitHub.copilot",
"kingwl.vscode-vitest-runner"
]
}
}
}
40 changes: 40 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Test action

on:
workflow_dispatch:
push:

jobs:
test_valid:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Run action
id: action_run
uses: ./
with:
context: test_valid
state: success
description: Valid test commit status


test_invalid_description:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Run action
id: action_run
uses: ./
with:
continue-on-error: true
context: test_invalid_description
state: error
description: 'A description that will exceed the maximum number of characters that can be used for a commit status description in the API. The current limit is 140 characters but might change in the future?'

- name: Fail if action succeeded
if: steps.action_run.outcome != 'failure'
run: exit 1
132 changes: 2 additions & 130 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,130 +1,2 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
lib
node_modules
22 changes: 22 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"debug.onTaskErrors": "showErrors",
"files.trimTrailingWhitespace": true,
"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.detectIndentation": false,
"[javascript]": {
"editor.tabSize": 2
},
"[typescript]": {
"editor.tabSize": 2
},
"[yaml]": {
"editor.tabSize": 2
},
"[html]": {
"editor.tabSize": 2
},
"[xml]": {
"editor.tabSize": 4
},
}
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
# github-commit-status
# github-commit-status

Adds a GitHub commit status to a repository for a specific commit.


## Inputs

* `repository`: The full repository name to set the commit status on in the form of `{owner}/{repo}`
* `sha`: The commit SHA that status is to be registered against, defaults to the `${{ github.sha }}` value which is based off the event that triggered the workflow
* `context`: The string label for the commit status to differntiate from other statuses
* `state`: The state of the commit status, must be one of `error`, `failure`, `pending`, `success`, defaults to `success`
* `description`: An optional description for the status, maximum `140` characters
* `target_url`: An optional URL for the commit status to be able to direct users to more details for the status
* `token`: The GitHub token to use to set the commit status, defaults to the Actions workflow token
* `github_api_url`: An optional URL to the REST API for the GitHub instance you are accessing. Defaults to the actions environment value


## Examples

Add a commit status recording unit tests passing for the current workflow:

```yaml
- name: Add commit status
uses: octodemo-resources/github-commit-status@v1
with:
context: unit_test_results
state: success
description: Tests passed
target_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
```
45 changes: 45 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: GitHub commit status action
description: Creates a GitHub commit status
author: Peter Murray

inputs:
repository:
description: 'The fully qualified name of the repository, e.g. octodemo/my-repo'
default: ${{ github.repository }}
required: false

sha:
description: 'The SHA of the commit to set the status on. Detects the correct place to apply the status based off the event for the trigger.'
required: false
default: ${{ github.sha }}

context:
description: 'The context name of the status, a string label to differentiate this status from the status of other systems.'
required: true

state:
description: The state of the status, can be one of error, failure, pending, or success.
default: success
required: false

description:
description: 'A short description of the status, limited to 256 character.'
required: false

target_url:
description: An optional URL to associate with the status.
required: false

token:
description: 'The GitHub token to use for authentication. Defaults to the token provided by the GitHub Actions environment.'
required: false
default: ${{ github.token }}

github_api_url:
description: 'The GitHub REST API URL to use. Defaults to the GitHub API provided by the GitHub Actions environment.'
required: false
default: ${{ github.api_url }}

runs:
using: node18
main: 'dist/index.js'
Loading

0 comments on commit f274e23

Please sign in to comment.