Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP]: Add support for Windows runners #88

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,34 @@ name: Docker

on:
push:
branches:
branches:
- main
tags: [ 'v*.*.*' ]
tags:
- v*.*.*
pull_request:
branches:
- main

env:
REGISTRY: ghcr.io
IMAGE_NAME: "liatrio/github-webhook"
IMAGE_NAME: liatrio/github-webhook

jobs:
docker-build:

strategy:
max-parallel: 2
fail-fast: false
matrix:
app: ['event-handler','runner-controller']
matrix:
app:
- event-handler
- runner-controller

runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand Down Expand Up @@ -61,7 +63,7 @@ jobs:
type=semver,pattern={{major}}.{{minor}}
type=sha
type=raw,latest

- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
Expand All @@ -76,5 +78,5 @@ jobs:
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
COSIGN_EXPERIMENTAL: "true"
COSIGN_EXPERIMENTAL: 'true'
run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,5 @@ __pycache__/
__blobstorage__
__queuestorage__
__azurite_db*__.json
.terraform
.terraform.lock.hcl
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,22 @@ The GitHub App serves as the foundation for sending webhook events to App A and

#### **Permissions for GitHub App**

| Permission | Access |
|:--------------------------------- |:--------------:|
| Repository: Actions | Read-only |
| Repository: Checks | Read-only |
| Repository: Metadata | Read-only |
| Permission | Access |
| :-------------------------------- | :------------: |
| Repository: Actions | Read-only |
| Repository: Checks | Read-only |
| Repository: Metadata | Read-only |
| Organization: Self-hosted runners | Read and write |

#### **Settings for Github App**

| Required Field | Value |
| --------------------------------------- |:--------------------:|
| GitHub App Name | {insert-name} |
| Homepage URL | {insert-any-url} |
| Webhook Active | False |
| Required Field | Value |
| --------------------------------------- | :------------------: |
| GitHub App Name | {insert-name} |
| Homepage URL | {insert-any-url} |
| Webhook Active | False |
| Webhook URL | |
| Subscribe to events | Workflow job |
| Subscribe to events | Workflow job |
| Where can this GitHub App be installed? | Only on this account |

*Note: You will need one GitHub App per org. Allowing installation to "Any account" makes it difficult to change access if installed on orgs outside your control.
Expand Down Expand Up @@ -125,7 +125,7 @@ The terraform output displays the Azure Function endpoint and secret, which you

### Deploy Function App and App Service

This terraform module is set up by default to use the latest version of both apps and deploy them on `terraform apply`. Specific versions found in our public [GitHub Packages](https://github.com/orgs/liatrio/packages?repo_name=terraform-azure-github-runner) and set in the terraform module inputs. If you choose to publish your own images, functionality to do so will be implemented soon™.
This terraform module is set up by default to use the latest version of both apps and deploy them on `terraform apply`. Specific versions can be found in our public [GitHub Packages](https://github.com/orgs/liatrio/packages?repo_name=terraform-azure-github-runner) and set in the terraform module inputs (*[variables.tf](./variables.tf) I believe?*). If you choose to publish your own images, functionality to do so will be implemented soon™.

### Setup the webhook and install the GitHub App

Expand Down
24 changes: 12 additions & 12 deletions app/event-handler/.eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ env:
es2021: true
node: true
extends:
- "@liatrio/eslint-config"
- '@liatrio/eslint-config'
parserOptions:
ecmaVersion: 2022
sourceType: module
rules:
"implicit-arrow-linebreak": "off"
"max-len":
- "error"
'implicit-arrow-linebreak': 'off'
'max-len':
- 'error'
- code: 120
ignoreStrings: true
ignoreTemplateLiterals: true
"no-await-in-loop": "off"
"no-process-exit": "off"
"security/detect-non-literal-require": "off"
"security/detect-non-literal-fs-filename": "off"
"security/detect-object-injection": "off"
"unicorn/no-await-expression-member": "off"
"unicorn/no-process-exit": "off"
"node/no-missing-import": "off"
'no-await-in-loop': 'off'
'no-process-exit': 'off'
'security/detect-non-literal-require': 'off'
'security/detect-non-literal-fs-filename': 'off'
'security/detect-object-injection': 'off'
'unicorn/no-await-expression-member': 'off'
'unicorn/no-process-exit': 'off'
'node/no-missing-import': 'off'
13 changes: 13 additions & 0 deletions app/event-handler/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Directories
node_modules
.obsidian
.vscode
.trash
.git
dist

# Files
.env
.gitignore
pnpm-lock.yaml
tsconfig.json
10 changes: 10 additions & 0 deletions app/event-handler/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"singleQuote": true,
"arrowParens": "avoid",
"semi": false,
"tabWidth": 2,
"useTabs": false,
"trailingComma": "es5",
"printWidth": 80,
"endOfLine": "lf"
}
4 changes: 1 addition & 3 deletions app/event-handler/eventHandler/function.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"post"
]
"methods": ["post"]
},
{
"type": "http",
Expand Down
47 changes: 25 additions & 22 deletions app/event-handler/eventHandler/index.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
import { validateRequest, getWebHookEventsQueueSender } from "./util.js";
import { validateRequest, getWebHookEventsQueueSender } from './util.js'

export const eventHandler = async function (context, req) {
context.log.verbose("JavaScript HTTP trigger function processed a request.", req.body);
context.log.verbose(
'JavaScript HTTP trigger function processed a request.',
req.body
)

const isValid = await validateRequest(context, req);
let response;
const isValid = await validateRequest(context, req)
let response

if (isValid) {
response = {
// status: 200, /* Defaults to 200 */
body: `Valid webhook message received. Queued [${req.body?.workflow_job?.run_url}] for processing`,
};
if (isValid) {
response = {
// status: 200, /* Defaults to 200 */
body: `Valid webhook message received. Queued [${req.body?.workflow_job?.run_url}] for processing`,
}

const sender = await getWebHookEventsQueueSender(context);
const sender = await getWebHookEventsQueueSender(context)

await sender.sendMessages({
body: req.body,
});
context.log.verbose("Placed message on queue", sender);
} else {
response = {
status: 403, /* Defaults to 200 */
body: "Discarding invalid request",
};
await sender.sendMessages({
body: req.body,
})
context.log.verbose('Placed message on queue', sender)
} else {
response = {
status: 403 /* Defaults to 200 */,
body: 'Discarding invalid request',
}
}

context.log.verbose("prepared response", response);
context.res = response;
};
context.log.verbose('prepared response', response)
context.res = response
}
Loading