generated from im-open/javascript-action-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from im-open/initial-action
ARCH-1029/ARCH-1030 - Adding the initial action to create a release and upload asset
- Loading branch information
Showing
6 changed files
with
21,553 additions
and
599 deletions.
There are no files selected for viewing
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,79 +1,82 @@ | ||
# javascript-action-template | ||
|
||
This template can be used to quickly start a new custom js action repository. Click the `Use this template` button at the top to get started. | ||
|
||
## TODOs | ||
- Readme | ||
- [ ] Update the Inputs section with the correct action inputs | ||
- [ ] Update the Outputs section with the correct action outputs | ||
- [ ] Update the Usage Example section with the correct usage | ||
- package.json | ||
- [ ] Update the `name` with the new action value | ||
- src/main.js | ||
- [ ] Implement your custom javascript action | ||
- action.yml | ||
- [ ] Fill in the correct name, description, inputs and outputs | ||
- .prettierrc.json | ||
- [ ] Update any preferences you might have | ||
- CODEOWNERS | ||
- [ ] Update as appropriate | ||
- Repository Settings | ||
- [ ] On the *Options* tab check the box to *Automatically delete head branches* | ||
- [ ] On the *Options* tab update the repository's visibility (must be done by an org owner) | ||
- [ ] On the *Branches* tab add a branch protection rule | ||
- [ ] Check *Require pull request reviews before merging* | ||
- [ ] Check *Dismiss stale pull request approvals when new commits are pushed* | ||
- [ ] Check *Require review from Code Owners* | ||
- [ ] Check *Include Administrators* | ||
- [ ] On the *Manage Access* tab add the appropriate groups | ||
- About Section (accessed on the main page of the repo, click the gear icon to edit) | ||
- [ ] The repo should have a short description of what it is for | ||
- [ ] Add one of the following topic tags: | ||
| Topic Tag | Usage | | ||
| --------------- | ---------------------------------------- | | ||
| az | For actions related to Azure | | ||
| code | For actions related to building code | | ||
| certs | For actions related to certificates | | ||
| db | For actions related to databases | | ||
| git | For actions related to Git | | ||
| iis | For actions related to IIS | | ||
| microsoft-teams | For actions related to Microsoft Teams | | ||
| svc | For actions related to Windows Services | | ||
| jira | For actions related to Jira | | ||
| meta | For actions related to running workflows | | ||
| pagerduty | For actions related to PagerDuty | | ||
| test | For actions related to testing | | ||
| tf | For actions related to Terraform | | ||
- [ ] Add any additional topics for an action if they apply | ||
- [ ] The Packages and Environments boxes can be unchecked | ||
|
||
# create-release | ||
|
||
This action can be used to create a GitHub Release and optionally upload an asset to the release. This action is based on two GitHub actions [create-release] and [upload-release-asset] which have been deprecated. | ||
|
||
This action has the option of uploading a single asset to the release. If more than one artifact is needed or if the artifact is not available when the release is created the [im-open/upload-release-asset] action can be used. | ||
|
||
This action also has the option of deleting the release if it already exists. If a workflow tries to create a release that already exists it will fail which may happen when a workflow is re-run. This functionality is also provided in the [im-open/delete-release-by-tag] action if a release needs to be deleted before the release is created. | ||
|
||
## Inputs | ||
| Parameter | Is Required | Default | Description | | ||
| --------- | ----------- | ------- | --------------------- | | ||
| `input-1` | true | | Description goes here | | ||
| `input-2` | false | | Description goes here | | ||
| Parameter | Is Required | Default | Description | | ||
| ------------------------- | -------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------ | | ||
| `github-token` | true | N/A | A token with permission to create and delete releases. Generally secrets.GITHUB_TOKEN. | | ||
| `tag-name` | true | N/A | The name of the tag. | | ||
| `release-name` | false | N/A | The name of the release. Defaults to the tag name if not provided. | | ||
| `commitish` | false | N/A | Any branch or commit SHA the Git tag is created from. Default: SHA of current commit. | | ||
| `body` | false | N/A | Text describing the contents of the release. | | ||
| `body-path` | false | N/A | Path to file with information about the release. | | ||
| `draft` | false | `false` | Flag indicating whether to create a draft (unpublished) release or a published one.<br/>Accepted Values: `true\|false`. Default: `false`. | | ||
| `prerelease` | false | `false` | Flag indicating whether this release is a pre-release or a full release.<br/>Accepted Values: `true\|false`. Default: `false`. | | ||
| `delete-existing-release` | false | `false` | Flag indicating whether to delete then re-create a release if it already exists.<br/>Accepted Values: `true\|false`. Default: `false`. | | ||
| `asset-path` | Required when uploading an asset | N/A | The path to the asset you want to upload. Required when uploading an asset. | | ||
| `asset-name` | Required when uploading an asset | N/A | The name of the asset you want to upload. Required when uploading an asset. | | ||
| `asset-content-type` | Required when uploading an asset | N/A | The content-type of the asset you want to upload. See the [supported Media Types]. Required when uploading an asset. | | ||
|
||
## Outputs | ||
| Output | Description | | ||
| ---------- | --------------------- | | ||
| `output-1` | Description goes here | | ||
| Output | Description | | ||
| ---------------------------- | ----------------------------------------------------------------- | | ||
| `release-id` | The id of the release. | | ||
| `release-html-url` | URL to the Release HTML Page | | ||
| `asset-upload-url` | URL for uploading assets to the release | | ||
| `asset-browser-download-url` | URL users can navigate to in order to download the uploaded asset | | ||
|
||
## Usage Examples | ||
|
||
```yml | ||
# TODO: Fill in the correct usage | ||
on: | ||
pull_request: | ||
types: [opened, reopened, synchronize] | ||
|
||
env: | ||
PROJECT_ROOT: './src/MyProj' | ||
DEPLOY_ZIP: 'published_app.zip' | ||
|
||
jobs: | ||
job1: | ||
runs-on: ubuntu-20.04 | ||
create-prebuilt-artifacts-release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Add Step Here | ||
uses: im-open/[email protected] | ||
- name: Calculate next version | ||
id: version | ||
uses: im-open/[email protected] | ||
with: | ||
calculate-prerelease-version: true | ||
branch-name: ${{ github.head_ref }} | ||
|
||
- name: Build, Publish and Zip App | ||
working-directory: ${{ env.PROJECT_ROOT }} | ||
run: | | ||
dotnet publish -c Release -o ./published_app | ||
(cd published_app && zip -r ../${{env.DEPLOY_ZIP}} .) | ||
- name: Create Pre-release | ||
id: create_release | ||
uses: im-open/[email protected] | ||
with: | ||
input-1: 'abc' | ||
input-2: '123 | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
tag-name: ${{ steps.version.outputs.VERSION }} | ||
prerelease: true | ||
asset-path: ${{ env.PROJECT_ROOT }}/${{ env.DEPLOY_ZIP }} | ||
asset-name: ${{ env.DEPLOY_ZIP }} | ||
asset-content-type: application/zip | ||
# The release might already exist if you hit 're-run jobs' on a workflow run that already | ||
# completed once. Creating a release when one already exists will fail, add the tag to delete it. | ||
delete-existing-release: true | ||
run-tests | ||
... | ||
``` | ||
|
||
## Recompiling | ||
|
@@ -87,7 +90,6 @@ npm run build | |
# Bundle the code (if dependencies are already installed) | ||
npm run bundle | ||
``` | ||
|
||
These commands utilize [esbuild](https://esbuild.github.io/getting-started/#bundling-for-node) to bundle the action and | ||
its dependencies into a single file located in the `dist` folder. | ||
|
||
|
@@ -98,3 +100,9 @@ This project has adopted the [im-open's Code of Conduct](https://github.com/im-o | |
## License | ||
|
||
Copyright © 2021, Extend Health, LLC. Code released under the [MIT license](LICENSE). | ||
|
||
[create-release]: https://github.com/actions/create-release | ||
[upload-release-asset]: https://github.com/actions/upload-release-asset | ||
[im-open/delete-release-by-tag]: https://github.com/im-open/delete-release-by-tag | ||
[im-open/upload-release-asset]: https://github.com/im-open/upload-release-asset | ||
[supported Media Types]: https://www.iana.org/assignments/media-types/media-types.xhtml |
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,19 +1,57 @@ | ||
name: 'JavaScript Action Template' | ||
|
||
description: 'Add description here' | ||
name: 'create-release' | ||
|
||
description: 'Create a release for a tag in your repository' | ||
author: 'GitHub' | ||
inputs: | ||
input-1: | ||
description: 'Add a description here' | ||
github-token: | ||
description: 'A token with permission to create and delete releases. Generally secrets.GITHUB_TOKEN.' | ||
required: true | ||
tag-name: | ||
description: 'The name of the tag.' | ||
required: true | ||
input-2: | ||
description: 'Add a description here' | ||
release-name: | ||
description: 'The name of the release. Defaults to the tag name if not provided.' | ||
required: false | ||
commitish: | ||
description: 'Any branch or commit SHA the Git tag is created from. Default: SHA of current commit.' | ||
required: false | ||
body: | ||
description: 'Text describing the contents of the release.' | ||
required: false | ||
body-path: | ||
description: 'Path to file with information about the release.' | ||
required: false | ||
draft: | ||
description: 'Flag indicating whether to create a draft (unpublished) release or a published one. Accepted Values: `true|false`. Default: `false`.' | ||
required: false | ||
default: 'false' | ||
prerelease: | ||
description: 'Flag indicating whether this release is a pre-release or a full release. Accepted Values: `true|false`. Default: `false`.' | ||
required: false | ||
default: 'false' | ||
delete-existing-release: | ||
description: 'Flag indicating whether to delete then re-create a release if it already exists. Accepted Values: `true|false`. Default: `false`.' | ||
required: false | ||
default: 'false' | ||
asset-path: | ||
description: 'The path to the asset you want to upload. Required when uploading an asset.' | ||
required: false | ||
asset-name: | ||
description: 'The name of the asset you want to upload. Required when uploading an asset.' | ||
required: false | ||
asset-content-type: | ||
description: 'The content-type of the asset you want to upload. See the supported Media Types here: https://www.iana.org/assignments/media-types/media-types.xhtml for more information. Required when uploading an asset.' | ||
required: false | ||
|
||
outputs: | ||
output-1: | ||
description: 'Add a description here' | ||
|
||
release-id: | ||
description: 'Release ID' | ||
release-html-url: | ||
description: 'URL to the Release HTML Page' | ||
asset-upload-url: | ||
description: 'URL for uploading assets to the release' | ||
asset-browser-download-url: | ||
description: 'URL users can navigate to in order to download the uploaded asset' | ||
runs: | ||
using: 'node12' | ||
main: 'dist/index.js' |
Oops, something went wrong.