Skip to content

Commit 5962447

Browse files
first commit
0 parents  commit 5962447

17 files changed

+22436
-0
lines changed

.eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist/
2+
lib/
3+
node_modules/

.eslintrc.json

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

.github/workflows/test.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: "build-test"
2+
on: # rebuild any PRs and main branch changes
3+
pull_request:
4+
push:
5+
branches:
6+
- master
7+
- 'releases/*'
8+
9+
jobs:
10+
build: # make sure build/ci work properly
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v1
14+
- run: |
15+
npm install
16+
npm run all
17+
test: # make sure the action works on a clean machine without building
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v1
21+
- uses: ./
22+
with:
23+
milliseconds: 1000

.gitignore

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Dependency directory
2+
node_modules
3+
4+
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
5+
# Logs
6+
logs
7+
*.log
8+
npm-debug.log*
9+
yarn-debug.log*
10+
yarn-error.log*
11+
lerna-debug.log*
12+
13+
# Diagnostic reports (https://nodejs.org/api/report.html)
14+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
15+
16+
# Runtime data
17+
pids
18+
*.pid
19+
*.seed
20+
*.pid.lock
21+
22+
# Directory for instrumented libs generated by jscoverage/JSCover
23+
lib-cov
24+
25+
# Coverage directory used by tools like istanbul
26+
coverage
27+
*.lcov
28+
29+
# nyc test coverage
30+
.nyc_output
31+
32+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
33+
.grunt
34+
35+
# Bower dependency directory (https://bower.io/)
36+
bower_components
37+
38+
# node-waf configuration
39+
.lock-wscript
40+
41+
# Compiled binary addons (https://nodejs.org/api/addons.html)
42+
build/Release
43+
44+
# Dependency directories
45+
jspm_packages/
46+
47+
# TypeScript v1 declaration files
48+
typings/
49+
50+
# TypeScript cache
51+
*.tsbuildinfo
52+
53+
# Optional npm cache directory
54+
.npm
55+
56+
# Optional eslint cache
57+
.eslintcache
58+
59+
# Optional REPL history
60+
.node_repl_history
61+
62+
# Output of 'npm pack'
63+
*.tgz
64+
65+
# Yarn Integrity file
66+
.yarn-integrity
67+
68+
# dotenv environment variables file
69+
.env
70+
.env.test
71+
72+
# parcel-bundler cache (https://parceljs.org/)
73+
.cache
74+
75+
# next.js build output
76+
.next
77+
78+
# nuxt.js build output
79+
.nuxt
80+
81+
# vuepress build output
82+
.vuepress/dist
83+
84+
# Serverless directories
85+
.serverless/
86+
87+
# FuseBox cache
88+
.fusebox/
89+
90+
# DynamoDB Local files
91+
.dynamodb/
92+
93+
# OS metadata
94+
.DS_Store
95+
Thumbs.db
96+
97+
# Ignore built ts files
98+
__tests__/runner/*
99+
lib/**/*

.prettierignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist/
2+
lib/
3+
node_modules/

.prettierrc.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"printWidth": 100,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": true,
6+
"singleQuote": true,
7+
"trailingComma": "none",
8+
"bracketSpacing": true,
9+
"arrowParens": "avoid",
10+
"parser": "typescript"
11+
}

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"typescript.tsdk": "node_modules/typescript/lib"
3+
}

LICENSE

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2018 GitHub, Inc. and contributors
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
THE SOFTWARE.

README.md

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<p align="center">
2+
<a href="https://github.com/actions/typescript-action/actions"><img alt="typescript-action status" src="https://github.com/actions/typescript-action/workflows/build-test/badge.svg"></a>
3+
</p>
4+
5+
# Create a JavaScript Action using TypeScript
6+
7+
Use this template to bootstrap the creation of a JavaScript action.:rocket:
8+
9+
This template includes compilication support, tests, a validation workflow, publishing, and versioning guidance.
10+
11+
If you are new, there's also a simpler introduction. See the [Hello World JavaScript Action](https://github.com/actions/hello-world-javascript-action)
12+
13+
## Create an action from this template
14+
15+
Click the `Use this Template` and provide the new repo details for your action
16+
17+
## Code in Master
18+
19+
Install the dependencies
20+
```bash
21+
$ npm install
22+
```
23+
24+
Build the typescript and package it for distribution
25+
```bash
26+
$ npm run build && npm run pack
27+
```
28+
29+
Run the tests :heavy_check_mark:
30+
```bash
31+
$ npm test
32+
33+
PASS ./index.test.js
34+
✓ throws invalid number (3ms)
35+
wait 500 ms (504ms)
36+
test runs (95ms)
37+
38+
...
39+
```
40+
41+
## Change action.yml
42+
43+
The action.yml contains defines the inputs and output for your action.
44+
45+
Update the action.yml with your name, description, inputs and outputs for your action.
46+
47+
See the [documentation](https://help.github.com/en/articles/metadata-syntax-for-github-actions)
48+
49+
## Change the Code
50+
51+
Most toolkit and CI/CD operations involve async operations so the action is run in an async function.
52+
53+
```javascript
54+
import * as core from '@actions/core';
55+
...
56+
57+
async function run() {
58+
try {
59+
...
60+
}
61+
catch (error) {
62+
core.setFailed(error.message);
63+
}
64+
}
65+
66+
run()
67+
```
68+
69+
See the [toolkit documentation](https://github.com/actions/toolkit/blob/master/README.md#packages) for the various packages.
70+
71+
## Publish to a distribution branch
72+
73+
Actions are run from GitHub repos so we will checkin the packed dist folder.
74+
75+
Then run [ncc](https://github.com/zeit/ncc) and push the results:
76+
```bash
77+
$ npm run pack
78+
$ git add dist
79+
$ git commit -a -m "prod dependencies"
80+
$ git push origin releases/v1
81+
```
82+
83+
Your action is now published! :rocket:
84+
85+
See the [versioning documentation](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md)
86+
87+
## Validate
88+
89+
You can now validate the action by referencing `./` in a workflow in your repo (see [test.yml](.github/workflows/test.yml)])
90+
91+
```yaml
92+
uses: ./
93+
with:
94+
milliseconds: 1000
95+
```
96+
97+
See the [actions tab](https://github.com/actions/javascript-action/actions) for runs of this action! :rocket:
98+
99+
## Usage:
100+
101+
After testing you can [create a v1 tag](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) to reference the stable and latest V1 action

__tests__/main.test.ts

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import * as process from 'process';
2+
import * as cp from 'child_process';
3+
import * as path from 'path';
4+
5+
// shows how the runner will run a javascript action with env / stdout protocol
6+
test('test runs', () => {
7+
process.env['ARCH'] = 'darwin';
8+
process.env['GITHUB_REPOSITORY'] = 'quizlet/cd-infra';
9+
process.env['INPUT_GITHUB-TOKEN'] = '500';
10+
process.env['INPUT_ARGOCD-VERSION'] = 'v1.6.1';
11+
process.env['INPUT_ARGOCD-SERVER-URL'] = 'argocd.qzlt.io';
12+
process.env['INPUT_ARGOCD-TOKEN'] = 'foo';
13+
const ip = path.join(__dirname, '..', 'lib', 'main.js');
14+
const options: cp.ExecSyncOptions = {
15+
env: process.env
16+
};
17+
console.log(cp.execSync(`node ${ip}`, options).toString());
18+
});
19+
20+
afterAll(() => {
21+
cp.execSync('rm -rf bin');
22+
});

action.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: 'ArgoCD Diff'
2+
description: 'Diffs all ArgoCD apps in the repo, and provides the diff as a PR comment'
3+
author: 'Quizlet'
4+
inputs:
5+
argocd-server-url:
6+
description: ArgoCD server url (without the protocol)
7+
required: true
8+
argocd-token:
9+
description: ArgoCD token for a local or project-scoped user https://argoproj.github.io/argo-cd/operator-manual/user-management/#local-usersaccounts-v15
10+
required: true
11+
argocd-version:
12+
description: ArgoCD Version
13+
default: v1.6.1
14+
required: false
15+
github-token:
16+
description: Github Token
17+
required: true
18+
runs:
19+
using: 'node12'
20+
main: 'dist/index.js'

0 commit comments

Comments
 (0)