Skip to content

Commit 6159767

Browse files
committed
Initial Commit
1 parent 4c8cc49 commit 6159767

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+30723
-0
lines changed

.eslintignore

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

.eslintrc.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"plugins": ["@typescript-eslint"],
3+
"extends": ["plugin:github/recommended"],
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-constant-condition": "off",
14+
"no-unused-vars": "off",
15+
"i18n-text/no-en": "off",
16+
"@typescript-eslint/no-unused-vars": "error",
17+
"@typescript-eslint/explicit-member-accessibility": ["error", {"accessibility": "no-public"}],
18+
"@typescript-eslint/no-require-imports": "error",
19+
"@typescript-eslint/array-type": "error",
20+
"@typescript-eslint/await-thenable": "error",
21+
"camelcase": "off",
22+
"@typescript-eslint/explicit-function-return-type": ["error", {"allowExpressions": true}],
23+
"@typescript-eslint/func-call-spacing": ["error", "never"],
24+
"@typescript-eslint/no-array-constructor": "error",
25+
"@typescript-eslint/no-empty-interface": "error",
26+
"@typescript-eslint/no-explicit-any": "warn",
27+
"@typescript-eslint/no-extraneous-class": "error",
28+
"@typescript-eslint/no-floating-promises": "error",
29+
"@typescript-eslint/no-for-in-array": "error",
30+
"@typescript-eslint/no-inferrable-types": "error",
31+
"@typescript-eslint/no-misused-new": "error",
32+
"@typescript-eslint/no-namespace": "error",
33+
"@typescript-eslint/no-non-null-assertion": "warn",
34+
"@typescript-eslint/no-unnecessary-qualifier": "error",
35+
"@typescript-eslint/no-unnecessary-type-assertion": "error",
36+
"@typescript-eslint/no-useless-constructor": "error",
37+
"@typescript-eslint/no-var-requires": "error",
38+
"@typescript-eslint/prefer-for-of": "warn",
39+
"@typescript-eslint/prefer-function-type": "warn",
40+
"@typescript-eslint/prefer-includes": "error",
41+
"@typescript-eslint/prefer-string-starts-ends-with": "error",
42+
"@typescript-eslint/promise-function-async": "error",
43+
"@typescript-eslint/require-array-sort-compare": "error",
44+
"@typescript-eslint/restrict-plus-operands": "error",
45+
"semi": "off",
46+
"@typescript-eslint/semi": ["error", "never"],
47+
"@typescript-eslint/type-annotation-spacing": "error",
48+
"@typescript-eslint/unbound-method": "error",
49+
"no-shadow": "off",
50+
"@typescript-eslint/no-shadow": ["error"]
51+
},
52+
"env": {
53+
"node": true,
54+
"es6": true
55+
}
56+
}

.github/workflows/build.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: CI - Build & Test
2+
on:
3+
pull_request:
4+
branches:
5+
- '*'
6+
paths-ignore:
7+
- '**.md'
8+
workflow_dispatch:
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- run: npm install
15+
name: Install dependencies
16+
- run: npm run bootstrap
17+
name: Bootstrap the packages
18+
- run: npm run build-all
19+
name: Build packages
20+
- run: npm run format-check
21+
- name: Check linter
22+
run: |
23+
npm run lint
24+
git diff --exit-code
25+
- name: Run tests
26+
run: npm run test

.github/workflows/release.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: CD - Release new version
2+
on:
3+
workflow_dispatch:
4+
jobs:
5+
build:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v3
9+
- run: npm install
10+
name: Install dependencies
11+
- run: npm run bootstrap
12+
name: Bootstrap the packages
13+
- run: npm run build-all
14+
name: Build packages
15+
- uses: actions/github-script@v6
16+
id: releaseNotes
17+
with:
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
script: |
20+
const fs = require('fs');
21+
const hookVersion = require('./package.json').version
22+
var releaseNotes = fs.readFileSync('${{ github.workspace }}/releaseNotes.md', 'utf8').replace(/<HOOK_VERSION>/g, hookVersion)
23+
console.log(releaseNotes)
24+
core.setOutput('version', hookVersion);
25+
core.setOutput('note', releaseNotes);
26+
- name: Zip up releases
27+
run: |
28+
zip -r -j actions-runner-hooks-docker-${{ steps.releaseNotes.outputs.version }}.zip packages/docker/dist
29+
zip -r -j actions-runner-hooks-k8s-${{ steps.releaseNotes.outputs.version }}.zip packages/k8s/dist
30+
- uses: actions/create-release@v1
31+
id: createRelease
32+
name: Create ${{ steps.releaseNotes.outputs.version }} Hook Release
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
with:
36+
tag_name: "v${{ steps.releaseNotes.outputs.version }}"
37+
release_name: "v${{ steps.releaseNotes.outputs.version }}"
38+
body: |
39+
${{ steps.releaseNotes.outputs.note }}
40+
- name: Upload K8s hooks
41+
uses: actions/upload-release-asset@v1
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
with:
45+
upload_url: ${{ steps.createRelease.outputs.upload_url }}
46+
asset_path: ${{ github.workspace }}/actions-runner-hooks-k8s-${{ steps.releaseNotes.outputs.version }}.zip
47+
asset_name: actions-runner-hooks-k8s-${{ steps.releaseNotes.outputs.version }}.zip
48+
asset_content_type: application/octet-stream
49+
- name: Upload docker hooks
50+
uses: actions/upload-release-asset@v1
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
with:
54+
upload_url: ${{ steps.createRelease.outputs.upload_url }}
55+
asset_path: ${{ github.workspace }}/actions-runner-hooks-docker-${{ steps.releaseNotes.outputs.version }}.zip
56+
asset_name: actions-runner-hooks-docker-${{ steps.releaseNotes.outputs.version }}.zip
57+
asset_content_type: application/octet-stream

.gitignore

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

.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: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"printWidth": 80,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": false,
6+
"singleQuote": true,
7+
"trailingComma": "none",
8+
"bracketSpacing": true,
9+
"arrowParens": "avoid",
10+
"parser": "typescript"
11+
}

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @actions/actions-runtime

CODE_OF_CONDUCT.MD

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to make participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies within all project spaces, and it also applies when
49+
an individual is representing the project or its community in public spaces.
50+
Examples of representing a project or community include using an official
51+
project e-mail address, posting via an official social media account, or acting
52+
as an appointed representative at an online or offline event. Representation of
53+
a project may be further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at [email protected]. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see
76+
https://www.contributor-covenant.org/faq

CONTRIBUTING.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Basic setup
2+
You'll need a runner compatible with hooks, a repository with container workflows to which you can register the runner and the hooks from this repository.
3+
4+
5+
6+
## Getting Started
7+
- Run ` npm install && npm run bootstrap` to setup your environment and install all the needed packages
8+
- Run `npm run lint` and `npm run format` to ensure your charges will pass CI
9+
- Run `npm run build-all` to build and test end to end.
10+
11+
12+
## E2E
13+
- You'll need a runner compatible with hooks, a repository with container workflows to which you can register the runner and the hooks from this repository.
14+
- See [the runner contributing.md](../../github/CONTRIBUTING.MD) for how to get started with runner development.
15+
- Build your hook using `npm run build`
16+
- Enable the hooks by setting `ACTIONS_RUNNER_CONTAINER_HOOK=./packages/{libraryname}/dist/index.js` file generated by [ncc](https://github.com/vercel/ncc)
17+
- Configure your self hosted runner against the a repository you have admin access
18+
- Run a workflow with a container job, for example
19+
```
20+
name: myjob
21+
on:
22+
workflow_dispatch:
23+
jobs:
24+
my_job:
25+
runs-on: self-hosted
26+
services:
27+
redis:
28+
image: redis
29+
container:
30+
image: alpine:3.15
31+
options: --cpus 1
32+
steps:
33+
- run: pwd
34+
```

LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright GitHub
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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
## Runner Container Hooks
2+
The Runner Container Hooks repo provides a set of packages that implement the container hooks feature in the [actions/runner](https://github.com/actions/runner). These can be used as is, or you can use them as a guide to implement your own hooks.
3+
4+
More information on how to implement your own hooks can be found in the [adr](https://github.com/actions/runner/pull/1891). The `examples` folder provides example inputs for each hook.
5+
6+
## Background
7+
8+
Three projects are included in the `packages` folder
9+
- k8s: A kubernetes hook implementation that spins up pods dynamically to run a job. More details can be found in the [readme](./packages/k8s/README.md)
10+
- docker: A hook implementation of the runner's docker implementation. More details can be found in the [readme](./packages/docker/README.md)
11+
- hooklib: a shared library which contains typescript definitions and utilities that the other projects consume
12+
13+
### Requirements
14+
15+
We welcome contributions. See [how to contribute to get started](./CONTRIBUTING.md).
16+
17+
## License
18+
19+
This project is licensed under the terms of the MIT open source license. Please refer to [MIT](./LICENSE.md) for the full terms.
20+
21+
## Maintainers
22+
23+
See the [Codeowners](./CODEOWNERS)
24+
25+
## Support
26+
27+
Find a bug? Please file an issue in this repository using the issue templates.
28+
29+
## Code of Conduct
30+
31+
See our [Code of Conduct](./CODE_OF_CONDUCT.MD)

SECURITY.MD

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Thanks for helping make GitHub safe for everyone.
2+
3+
## Security
4+
5+
GitHub takes the security of our software products and services seriously, including all of the open source code repositories managed through our GitHub organizations, such as [GitHub](https://github.com/GitHub).
6+
7+
Even though [open source repositories are outside of the scope of our bug bounty program](https://bounty.github.com/index.html#scope) and therefore not eligible for bounty rewards, we will ensure that your finding gets passed along to the appropriate maintainers for remediation.
8+
9+
## Reporting Security Issues
10+
11+
If you believe you have found a security vulnerability in any GitHub-owned repository, please report it to us through coordinated disclosure.
12+
13+
**Please do not report security vulnerabilities through public GitHub issues, discussions, or pull requests.**
14+
15+
Instead, please send an email to opensource-security[@]github.com.
16+
17+
Please include as much of the information listed below as you can to help us better understand and resolve the issue:
18+
19+
* The type of issue (e.g., buffer overflow, SQL injection, or cross-site scripting)
20+
* Full paths of source file(s) related to the manifestation of the issue
21+
* The location of the affected source code (tag/branch/commit or direct URL)
22+
* Any special configuration required to reproduce the issue
23+
* Step-by-step instructions to reproduce the issue
24+
* Proof-of-concept or exploit code (if possible)
25+
* Impact of the issue, including how an attacker might exploit the issue
26+
27+
This information will help us triage your report more quickly.
28+
29+
## Policy
30+
31+
See [GitHub's Safe Harbor Policy](https://docs.github.com/en/github/site-policy/github-bug-bounty-program-legal-safe-harbor#1-safe-harbor-terms)

0 commit comments

Comments
 (0)