generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
10,853 additions
and
864 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: renovate | ||
on: | ||
pull_request: | ||
workflow_dispatch: {} | ||
schedule: | ||
- cron: "0 */6 * * *" | ||
jobs: | ||
renovate: | ||
name: Update | ||
if: github.event_name != 'pull_request' | ||
uses: urcomputeringpal/.github/.github/workflows/renovate.yaml@main | ||
with: | ||
renovate_app_slug: ur-renovate | ||
onboarding: "true" | ||
secrets: | ||
RENOVATE_APP_ID: ${{ secrets.RENOVATE_APP_ID }} | ||
RENOVATE_APP_PEM: ${{ secrets.RENOVATE_APP_PEM }} | ||
|
||
validate: | ||
name: Validate | ||
if: github.event_name == 'pull_request' | ||
uses: urcomputeringpal/.github/.github/workflows/renovate.yaml@main | ||
with: | ||
renovate_app_slug: ur-renovate | ||
dry_run_branch: ${{ github.event.pull_request.head.ref }} | ||
secrets: | ||
RENOVATE_APP_ID: ${{ secrets.RENOVATE_APP_ID }} | ||
RENOVATE_APP_PEM: ${{ secrets.RENOVATE_APP_PEM }} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: Update Major Version Tag | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
|
||
jobs: | ||
update-majorver: | ||
name: Update Major Version Tag | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: nowactions/update-majorver@f2014bbbba95b635e990ce512c5653bd0f4753fb # v1.1.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,105 +1,32 @@ | ||
<p align="center"> | ||
<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> | ||
</p> | ||
# Pulumi Preview PR Label Action | ||
|
||
# Create a JavaScript Action using TypeScript | ||
Decorate your PR with context Pulumi Preview output | ||
|
||
Use this template to bootstrap the creation of a TypeScript action.:rocket: | ||
See [./action.yml](./action.yml) for the full documentation for this action's inputs and outputs. | ||
|
||
This template includes compilation support, tests, a validation workflow, publishing, and versioning guidance. | ||
|
||
If you are new, there's also a simpler introduction. See the [Hello World JavaScript Action](https://github.com/actions/hello-world-javascript-action) | ||
|
||
## Create an action from this template | ||
|
||
Click the `Use this Template` and provide the new repo details for your action | ||
|
||
## Code in Main | ||
|
||
> First, you'll need to have a reasonably modern version of `node` handy. This won't work with versions older than 9, for instance. | ||
Install the dependencies | ||
```bash | ||
$ npm install | ||
``` | ||
|
||
Build the typescript and package it for distribution | ||
```bash | ||
$ npm run build && npm run package | ||
``` | ||
|
||
Run the tests :heavy_check_mark: | ||
```bash | ||
$ npm test | ||
|
||
PASS ./index.test.js | ||
✓ throws invalid number (3ms) | ||
✓ wait 500 ms (504ms) | ||
✓ test runs (95ms) | ||
|
||
... | ||
``` | ||
|
||
## Change action.yml | ||
|
||
The action.yml defines the inputs and output for your action. | ||
|
||
Update the action.yml with your name, description, inputs and outputs for your action. | ||
|
||
See the [documentation](https://help.github.com/en/articles/metadata-syntax-for-github-actions) | ||
|
||
## Change the Code | ||
|
||
Most toolkit and CI/CD operations involve async operations so the action is run in an async function. | ||
|
||
```javascript | ||
import * as core from '@actions/core'; | ||
... | ||
|
||
async function run() { | ||
try { | ||
... | ||
} | ||
catch (error) { | ||
core.setFailed(error.message); | ||
} | ||
} | ||
|
||
run() | ||
``` | ||
|
||
See the [toolkit documentation](https://github.com/actions/toolkit/blob/master/README.md#packages) for the various packages. | ||
|
||
## Publish to a distribution branch | ||
|
||
Actions are run from GitHub repos so we will checkin the packed dist folder. | ||
|
||
Then run [ncc](https://github.com/zeit/ncc) and push the results: | ||
```bash | ||
$ npm run package | ||
$ git add dist | ||
$ git commit -a -m "prod dependencies" | ||
$ git push origin releases/v1 | ||
``` | ||
|
||
Note: We recommend using the `--license` option for ncc, which will create a license file for all of the production node modules used in your project. | ||
|
||
Your action is now published! :rocket: | ||
|
||
See the [versioning documentation](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) | ||
|
||
## Validate | ||
|
||
You can now validate the action by referencing `./` in a workflow in your repo (see [test.yml](.github/workflows/test.yml)) | ||
## Example | ||
|
||
The following example demonstrates how to use this with [pulumi/actions](https://github.com/pulumi/actions): | ||
|
||
```yaml | ||
uses: ./ | ||
with: | ||
milliseconds: 1000 | ||
name: pulumi-preview | ||
on: [pull_request] | ||
jobs: | ||
preview: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
issues: write | ||
pull-requests: write | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: pulumi/actions@v4 | ||
id: pulumi-preview | ||
with: | ||
work-dir: pulumi | ||
command: preview | ||
- uses: urcomputeringpal/pulumi-preview-pr-label-action@v0 | ||
with: | ||
label-prefix: Production | ||
pulumi-output: ${{ steps.pulumi-preview.outputs.output }} | ||
``` | ||
See the [actions tab](https://github.com/actions/typescript-action/actions) for runs of this action! :rocket: | ||
## Usage: | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,44 @@ | ||
import {wait} from '../src/wait' | ||
import * as process from 'process' | ||
import * as cp from 'child_process' | ||
import * as path from 'path' | ||
import {computeLabels} from '../src/labels' | ||
import {expect, test} from '@jest/globals' | ||
|
||
test('throws invalid number', async () => { | ||
const input = parseInt('foo', 10) | ||
await expect(wait(input)).rejects.toThrow('milliseconds not a number') | ||
test('only some', async () => { | ||
const pulumiOutput = ` | ||
~ 4 to update | ||
+-8 to replace | ||
` | ||
|
||
const labels = await computeLabels(pulumiOutput, 'production') | ||
expect(labels.add).toContain('production changes') | ||
expect(labels.add).toContain('production replacements') | ||
expect(labels.remove).toContain('production creations') | ||
expect(labels.remove).toContain('production deletions') | ||
expect(labels.remove).toContain('production noop') | ||
}) | ||
|
||
test('wait 500 ms', async () => { | ||
const start = new Date() | ||
await wait(500) | ||
const end = new Date() | ||
var delta = Math.abs(end.getTime() - start.getTime()) | ||
expect(delta).toBeGreaterThan(450) | ||
test('all', async () => { | ||
const pulumiOutput = ` | ||
+ 5 to create | ||
~ 4 to update | ||
- 5 to delete | ||
+-9 to replace | ||
` | ||
|
||
const labels = await computeLabels(pulumiOutput, 'production') | ||
expect(labels.add).toContain('production changes') | ||
expect(labels.add).toContain('production replacements') | ||
expect(labels.add).toContain('production creations') | ||
expect(labels.add).toContain('production deletions') | ||
expect(labels.remove).toContain('production noop') | ||
}) | ||
|
||
// shows how the runner will run a javascript action with env / stdout protocol | ||
test('test runs', () => { | ||
process.env['INPUT_MILLISECONDS'] = '500' | ||
const np = process.execPath | ||
const ip = path.join(__dirname, '..', 'lib', 'main.js') | ||
const options: cp.ExecFileSyncOptions = { | ||
env: process.env | ||
} | ||
console.log(cp.execFileSync(np, [ip], options).toString()) | ||
test('noop', async () => { | ||
const pulumiOutput = ` | ||
` | ||
|
||
const labels = await computeLabels(pulumiOutput, 'production') | ||
expect(labels.remove).toContain('production changes') | ||
expect(labels.remove).toContain('production replacements') | ||
expect(labels.remove).toContain('production creations') | ||
expect(labels.remove).toContain('production deletions') | ||
expect(labels.add).toContain('production noop') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
name: 'Your name here' | ||
description: 'Provide a description here' | ||
author: 'Your name or organization here' | ||
name: Pulumi Preview PR Label Action | ||
description: Decorate your PR with context from Pulumi Preview output. | ||
author: "@urcomputeringpal" | ||
inputs: | ||
milliseconds: # change this | ||
github-token: | ||
description: Token to use | ||
default: ${{ github.token }} | ||
pulumi-output: | ||
description: Pulumi output to parse | ||
required: true | ||
description: 'input description here' | ||
default: 'default value if applicable' | ||
label-prefix: | ||
description: String to prefix your label with | ||
default: Pulumi | ||
|
||
runs: | ||
using: 'node16' | ||
main: 'dist/index.js' |
Oops, something went wrong.