Skip to content

Commit

Permalink
dockerode
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Wagner committed Jun 4, 2021
1 parent b595b59 commit e12b5f1
Show file tree
Hide file tree
Showing 10 changed files with 36,321 additions and 2,025 deletions.
36,499 changes: 34,564 additions & 1,935 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

1,201 changes: 1,129 additions & 72 deletions dist/licenses.txt

Large diffs are not rendered by default.

Binary file added dist/pagent.exe
Binary file not shown.
483 changes: 468 additions & 15 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@
"dependencies": {
"@actions/core": "^1.3.0",
"@actions/github": "^5.0.0",
"@octokit/webhooks-definitions": "^3.67.3"
"@octokit/webhooks-definitions": "^3.67.3",
"dockerode": "^3.3.0"
},
"devDependencies": {
"@types/dockerode": "^3.2.3",
"@types/jest": "^26.0.23",
"@types/node": "^15.12.0",
"@typescript-eslint/parser": "^4.26.0",
Expand Down
12 changes: 12 additions & 0 deletions script/hack
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh -e

ROOT=$(dirname "$0")/..
export ROOT

cd $ROOT
npm run build
npm run package

GITHUB_EVENT_NAME=repository_dispatch \
GITHUB_EVENT_PATH="${ROOT}/script/hack-event.json" \
node dist/index.js
126 changes: 126 additions & 0 deletions script/hack-event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
{
"action": "on-demand-test",
"branch": "master",
"client_payload": {
"dependabotAPI": "https://f34f9fbb7a6a.ngrok.io",
"jobID": "8",
"jobToken": "QkNM+m1lDFieJ0V6DAwUY+hG6PUKItjuS7EApTVsTQw=",
"credentialsToken": "hMAqnnY+CJGUCQjKRUzSZnR+DnbW5YEA5nL2xh8zovk=",
"updaterImage": "docker.io/library/dependabot-updater:latest",
"proxyImage": "docker.io/dependabot/update-job-proxy:latest"
},
"repository": {
"archive_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/{archive_format}{/ref}",
"archived": false,
"assignees_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/assignees{/user}",
"blobs_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/git/blobs{/sha}",
"branches_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/branches{/branch}",
"clone_url": "https://github.com/thepwagner/dependabot-test-npm.git",
"collaborators_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/collaborators{/collaborator}",
"comments_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/comments{/number}",
"commits_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/commits{/sha}",
"compare_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/compare/{base}...{head}",
"contents_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/contents/{+path}",
"contributors_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/contributors",
"created_at": "2019-08-03T00:13:15Z",
"default_branch": "master",
"deployments_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/deployments",
"description": null,
"disabled": false,
"downloads_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/downloads",
"events_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/events",
"fork": false,
"forks": 0,
"forks_count": 0,
"forks_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/forks",
"full_name": "thepwagner/dependabot-test-npm",
"git_commits_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/git/commits{/sha}",
"git_refs_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/git/refs{/sha}",
"git_tags_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/git/tags{/sha}",
"git_url": "git://github.com/thepwagner/dependabot-test-npm.git",
"has_downloads": true,
"has_issues": true,
"has_pages": false,
"has_projects": false,
"has_wiki": false,
"homepage": null,
"hooks_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/hooks",
"html_url": "https://github.com/thepwagner/dependabot-test-npm",
"id": 200312318,
"issue_comment_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/issues/comments{/number}",
"issue_events_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/issues/events{/number}",
"issues_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/issues{/number}",
"keys_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/keys{/key_id}",
"labels_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/labels{/name}",
"language": null,
"languages_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/languages",
"license": null,
"merges_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/merges",
"milestones_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/milestones{/number}",
"mirror_url": null,
"name": "dependabot-test-npm",
"node_id": "MDEwOlJlcG9zaXRvcnkyMDAzMTIzMTg=",
"notifications_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/notifications{?since,all,participating}",
"open_issues": 2,
"open_issues_count": 2,
"owner": {
"avatar_url": "https://avatars1.githubusercontent.com/u/1559510?v=4",
"events_url": "https://api.github.com/users/thepwagner/events{/privacy}",
"followers_url": "https://api.github.com/users/thepwagner/followers",
"following_url": "https://api.github.com/users/thepwagner/following{/other_user}",
"gists_url": "https://api.github.com/users/thepwagner/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/thepwagner",
"id": 1559510,
"login": "thepwagner",
"node_id": "MDQ6VXNlcjE1NTk1MTA=",
"organizations_url": "https://api.github.com/users/thepwagner/orgs",
"received_events_url": "https://api.github.com/users/thepwagner/received_events",
"repos_url": "https://api.github.com/users/thepwagner/repos",
"site_admin": true,
"starred_url": "https://api.github.com/users/thepwagner/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/thepwagner/subscriptions",
"type": "User",
"url": "https://api.github.com/users/thepwagner"
},
"private": true,
"pulls_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/pulls{/number}",
"pushed_at": "2020-01-22T14:40:42Z",
"releases_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/releases{/id}",
"size": 77,
"ssh_url": "git@github.com:thepwagner/dependabot-test-npm.git",
"stargazers_count": 0,
"stargazers_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/stargazers",
"statuses_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/statuses/{sha}",
"subscribers_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/subscribers",
"subscription_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/subscription",
"svn_url": "https://github.com/thepwagner/dependabot-test-npm",
"tags_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/tags",
"teams_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/teams",
"trees_url": "https://api.github.com/repos/thepwagner/dependabot-test-npm/git/trees{/sha}",
"updated_at": "2020-01-22T14:40:45Z",
"url": "https://api.github.com/repos/thepwagner/dependabot-test-npm",
"watchers": 0,
"watchers_count": 0
},
"sender": {
"avatar_url": "https://avatars1.githubusercontent.com/u/1559510?v=4",
"events_url": "https://api.github.com/users/thepwagner/events{/privacy}",
"followers_url": "https://api.github.com/users/thepwagner/followers",
"following_url": "https://api.github.com/users/thepwagner/following{/other_user}",
"gists_url": "https://api.github.com/users/thepwagner/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/thepwagner",
"id": 1559510,
"login": "thepwagner",
"node_id": "MDQ6VXNlcjE1NTk1MTA=",
"organizations_url": "https://api.github.com/users/thepwagner/orgs",
"received_events_url": "https://api.github.com/users/thepwagner/received_events",
"repos_url": "https://api.github.com/users/thepwagner/repos",
"site_admin": true,
"starred_url": "https://api.github.com/users/thepwagner/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/thepwagner/subscriptions",
"type": "User",
"url": "https://api.github.com/users/thepwagner"
}
}
9 changes: 8 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import * as core from '@actions/core'
import * as github from '@actions/github'
import {getInputs} from './inputs'
import Docker from 'dockerode'
import {runFileFetcher} from './updater/fetcher'

async function run(): Promise<void> {
try {
const input = getInputs(github.context)
if (input === null) {
return
}

core.info(`processing job: ${JSON.stringify(input)}`)

// TODO: api client: fetch job details

// TODO: the full docker jamboree
const docker = new Docker()
await runFileFetcher(docker)
} catch (error) {
core.setFailed(error.message)
}
Expand Down
10 changes: 10 additions & 0 deletions src/updater/fetcher.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as core from '@actions/core'
import * as Docker from 'dockerode'

export async function runFileFetcher(docker: Docker): Promise<void> {
// hello docker
const containers = await docker.listContainers()
for (const container of containers) {
core.info(`Container ${container.Id} - ${container.Names}`)
}
}

0 comments on commit e12b5f1

Please sign in to comment.