From 02d782dfdf3c90489fa15784b2fee1acc1cbfa8e Mon Sep 17 00:00:00 2001 From: Nick Satterly Date: Fri, 13 Nov 2020 00:46:00 +0100 Subject: [PATCH] Add test data and print env vars --- __tests__/fixtures/manual.json | 139 +++++++++++++++++++++++++++++++ __tests__/fixtures/schedule.json | 3 + src/main.ts | 1 + src/slack.ts | 7 ++ 4 files changed, 150 insertions(+) create mode 100644 __tests__/fixtures/manual.json create mode 100644 __tests__/fixtures/schedule.json diff --git a/__tests__/fixtures/manual.json b/__tests__/fixtures/manual.json new file mode 100644 index 00000000..5c9263b5 --- /dev/null +++ b/__tests__/fixtures/manual.json @@ -0,0 +1,139 @@ +{ + "inputs": null, + "organization": { + "avatar_url": "https://avatars1.githubusercontent.com/u/65077766?v=4", + "description": "Automate your GitHub workflows with custom actions", + "events_url": "https://api.github.com/orgs/act10ns/events", + "hooks_url": "https://api.github.com/orgs/act10ns/hooks", + "id": 65077766, + "issues_url": "https://api.github.com/orgs/act10ns/issues", + "login": "act10ns", + "members_url": "https://api.github.com/orgs/act10ns/members{/member}", + "node_id": "MDEyOk9yZ2FuaXphdGlvbjY1MDc3NzY2", + "public_members_url": "https://api.github.com/orgs/act10ns/public_members{/member}", + "repos_url": "https://api.github.com/orgs/act10ns/repos", + "url": "https://api.github.com/orgs/act10ns" + }, + "ref": "refs/heads/master", + "repository": { + "archive_url": "https://api.github.com/repos/act10ns/slack/{archive_format}{/ref}", + "archived": false, + "assignees_url": "https://api.github.com/repos/act10ns/slack/assignees{/user}", + "blobs_url": "https://api.github.com/repos/act10ns/slack/git/blobs{/sha}", + "branches_url": "https://api.github.com/repos/act10ns/slack/branches{/branch}", + "clone_url": "https://github.com/act10ns/slack.git", + "collaborators_url": "https://api.github.com/repos/act10ns/slack/collaborators{/collaborator}", + "comments_url": "https://api.github.com/repos/act10ns/slack/comments{/number}", + "commits_url": "https://api.github.com/repos/act10ns/slack/commits{/sha}", + "compare_url": "https://api.github.com/repos/act10ns/slack/compare/{base}...{head}", + "contents_url": "https://api.github.com/repos/act10ns/slack/contents/{+path}", + "contributors_url": "https://api.github.com/repos/act10ns/slack/contributors", + "created_at": "2020-05-09T14:04:36Z", + "default_branch": "master", + "deployments_url": "https://api.github.com/repos/act10ns/slack/deployments", + "description": "Slack messages for GitHub Action workflows, jobs and steps", + "disabled": false, + "downloads_url": "https://api.github.com/repos/act10ns/slack/downloads", + "events_url": "https://api.github.com/repos/act10ns/slack/events", + "fork": false, + "forks": 1, + "forks_count": 1, + "forks_url": "https://api.github.com/repos/act10ns/slack/forks", + "full_name": "act10ns/slack", + "git_commits_url": "https://api.github.com/repos/act10ns/slack/git/commits{/sha}", + "git_refs_url": "https://api.github.com/repos/act10ns/slack/git/refs{/sha}", + "git_tags_url": "https://api.github.com/repos/act10ns/slack/git/tags{/sha}", + "git_url": "git://github.com/act10ns/slack.git", + "has_downloads": true, + "has_issues": true, + "has_pages": false, + "has_projects": true, + "has_wiki": true, + "homepage": "https://github.com/marketplace/actions/slack-github-actions-slack-integration", + "hooks_url": "https://api.github.com/repos/act10ns/slack/hooks", + "html_url": "https://github.com/act10ns/slack", + "id": 262583918, + "issue_comment_url": "https://api.github.com/repos/act10ns/slack/issues/comments{/number}", + "issue_events_url": "https://api.github.com/repos/act10ns/slack/issues/events{/number}", + "issues_url": "https://api.github.com/repos/act10ns/slack/issues{/number}", + "keys_url": "https://api.github.com/repos/act10ns/slack/keys{/key_id}", + "labels_url": "https://api.github.com/repos/act10ns/slack/labels{/name}", + "language": "TypeScript", + "languages_url": "https://api.github.com/repos/act10ns/slack/languages", + "license": { + "key": "mit", + "name": "MIT License", + "node_id": "MDc6TGljZW5zZTEz", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit" + }, + "merges_url": "https://api.github.com/repos/act10ns/slack/merges", + "milestones_url": "https://api.github.com/repos/act10ns/slack/milestones{/number}", + "mirror_url": null, + "name": "slack", + "node_id": "MDEwOlJlcG9zaXRvcnkyNjI1ODM5MTg=", + "notifications_url": "https://api.github.com/repos/act10ns/slack/notifications{?since,all,participating}", + "open_issues": 12, + "open_issues_count": 12, + "owner": { + "avatar_url": "https://avatars1.githubusercontent.com/u/65077766?v=4", + "events_url": "https://api.github.com/users/act10ns/events{/privacy}", + "followers_url": "https://api.github.com/users/act10ns/followers", + "following_url": "https://api.github.com/users/act10ns/following{/other_user}", + "gists_url": "https://api.github.com/users/act10ns/gists{/gist_id}", + "gravatar_id": "", + "html_url": "https://github.com/act10ns", + "id": 65077766, + "login": "act10ns", + "node_id": "MDEyOk9yZ2FuaXphdGlvbjY1MDc3NzY2", + "organizations_url": "https://api.github.com/users/act10ns/orgs", + "received_events_url": "https://api.github.com/users/act10ns/received_events", + "repos_url": "https://api.github.com/users/act10ns/repos", + "site_admin": false, + "starred_url": "https://api.github.com/users/act10ns/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/act10ns/subscriptions", + "type": "Organization", + "url": "https://api.github.com/users/act10ns" + }, + "private": false, + "pulls_url": "https://api.github.com/repos/act10ns/slack/pulls{/number}", + "pushed_at": "2020-11-12T23:04:39Z", + "releases_url": "https://api.github.com/repos/act10ns/slack/releases{/id}", + "size": 1424, + "ssh_url": "git@github.com:act10ns/slack.git", + "stargazers_count": 22, + "stargazers_url": "https://api.github.com/repos/act10ns/slack/stargazers", + "statuses_url": "https://api.github.com/repos/act10ns/slack/statuses/{sha}", + "subscribers_url": "https://api.github.com/repos/act10ns/slack/subscribers", + "subscription_url": "https://api.github.com/repos/act10ns/slack/subscription", + "svn_url": "https://github.com/act10ns/slack", + "tags_url": "https://api.github.com/repos/act10ns/slack/tags", + "teams_url": "https://api.github.com/repos/act10ns/slack/teams", + "trees_url": "https://api.github.com/repos/act10ns/slack/git/trees{/sha}", + "updated_at": "2020-11-12T23:02:42Z", + "url": "https://api.github.com/repos/act10ns/slack", + "watchers": 22, + "watchers_count": 22 + }, + "sender": { + "avatar_url": "https://avatars0.githubusercontent.com/u/615057?v=4", + "events_url": "https://api.github.com/users/satterly/events{/privacy}", + "followers_url": "https://api.github.com/users/satterly/followers", + "following_url": "https://api.github.com/users/satterly/following{/other_user}", + "gists_url": "https://api.github.com/users/satterly/gists{/gist_id}", + "gravatar_id": "", + "html_url": "https://github.com/satterly", + "id": 615057, + "login": "satterly", + "node_id": "MDQ6VXNlcjYxNTA1Nw==", + "organizations_url": "https://api.github.com/users/satterly/orgs", + "received_events_url": "https://api.github.com/users/satterly/received_events", + "repos_url": "https://api.github.com/users/satterly/repos", + "site_admin": false, + "starred_url": "https://api.github.com/users/satterly/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/satterly/subscriptions", + "type": "User", + "url": "https://api.github.com/users/satterly" + }, + "workflow": ".github/workflows/manual.yml" +} \ No newline at end of file diff --git a/__tests__/fixtures/schedule.json b/__tests__/fixtures/schedule.json new file mode 100644 index 00000000..78cd58c9 --- /dev/null +++ b/__tests__/fixtures/schedule.json @@ -0,0 +1,3 @@ +{ + "schedule": "*/15 * * * *" +} \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index 45e5464f..e9def3c6 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,6 +2,7 @@ import * as core from '@actions/core' import send from './slack' async function run(): Promise { + try { const url = process.env.SLACK_WEBHOOK_URL as string const jobName = process.env.GITHUB_JOB as string diff --git a/src/slack.ts b/src/slack.ts index 2cb07481..6fe0a621 100644 --- a/src/slack.ts +++ b/src/slack.ts @@ -23,6 +23,13 @@ async function send( jobSteps: object, channel?: string ): Promise { + + core.debug('******** ENVVAR ********') + for (var k of Object.keys(process.env).sort()) { + core.debug(`${k} = ${process.env[k]}`) + } + + core.debug('******** PAYLOAD ********') core.debug(JSON.stringify(context.payload, null, 2)) const workflow = context.workflow