Skip to content

Commit

Permalink
fix: readme and action yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
lennartquerter committed Nov 30, 2022
1 parent f104e32 commit 0740890
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 71 deletions.
28 changes: 9 additions & 19 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
name: 'Bump version from tag'
description: 'Bumps a semver version from tag or fallback version'
name: 'Send a message on slack'
description: 'Creates a message in the channel by a webhook'
inputs:
token:
description: 'Github token used by octokit (github API)'
slack_webhook_url:
description: 'Webhook URL (with channel and token)'
required: true
build_number:
description: 'Optional: used to generate the pre_release_version as {version}-alpha.{build_number}. (Default: 0)'
required: false
fallback_tag:
description: 'Optional: used as fallback when no tag/release can be found on the repository.'
required: false
disable_inform:
description: 'Disables the comment created by the script. (Default: false)'
message:
description: 'the message that will be posted'
required: true
is_markdown:
description: 'Optional: is the message in markdown format (default: false)'
required: false
outputs:
old_version:
description: 'The latest tag found'
new_version:
description: 'The next calculated version'
pre_release_version:
description: 'Pre release version built from {new_version}-alpha.{build_number}'
runs:
using: 'node16'
main: 'dist/index.js'
6 changes: 1 addition & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9037,11 +9037,7 @@ async function execute() {
function getAndValidateInput() {
const slackWebhookUrl = core.getInput('slack_webhook_url', {required: true})
const message = core.getInput('message', {required: true})
let isMarkdown = core.getInput('is_markdown', {required: false})

if (!isMarkdown) {
isMarkdown = false;
}
let isMarkdown = core.getInput('is_markdown', {required: false}) === 'true'

return {
slackWebhookUrl,
Expand Down
57 changes: 15 additions & 42 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,34 @@
# Action: SemVer bump from tags (with PR comment!)
# Action: Send a notification to slack

This action will fetch the latest tag/release created and bump the version with the level specific in the label of the PR.
If no label is found, we will use a 'patch' bump.

## Inputs

### `token`
### `slack_webhook_url`

**Required** The secret used to access github
**Required** URL of the webhook called. You can create this webhook by creating a slack app. Follow the guide [here](https://slack.com/help/articles/115005265063-Incoming-webhooks-for-Slack)

### `build_number`
### `message`

Used to build the pre-release version (Default: `0`)
**Required** The message you would like to send

### `fallback_tag`
### `is_markdown`

If no tag has been found (in the tags), this tag will be used. Should be a Semantic Version valid tag.
If no tag can be found, and no fallback_tag is provided, we will throw an error.

### `disable_inform`

If true, we will not post a message on the pull_request. (Default: `false`)

## Outputs

### `old_version`

The current version that we found (could be the fallback version provided if none is found)

### `new_version`

The next version we will build, based on semVer with the {inputs.level} as bump parameter

### `pre_release_version`

The next pre-release version tag ({new_version}-alpha.{inputs.build_number})
## No outputs

## Example usage

Get the tag by using the action:
Send a message on slack

```yaml
name: Bump version from tag
id: tag
uses: freight-hub/action-tag-bump-version@v1.3
name: Notify slack
id: slack
uses: freight-hub/action-slack-notify@v1.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
build_number: ${{ github.run_number }}
fallback_tag: 0.0.1
disable_inform: false
```
Update the yarn version with the output:
```yaml
- run: yarn version --new-version ${{ steps.tag.outputs.new_version }} --no-git-tag-version
- run: yarn version --new-version ${{ steps.tag.outputs.pre_release_version }} --no-git-tag-version
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
message: 'hello channel!'
is_markdown: false
```
## Contributing
Expand All @@ -66,4 +39,4 @@ When contributing to this library there are some points to note:
2. The `dist` folder is checked in (we compile the node_modules into it with `@vercel/ncc`)
- this is because we need to include the complete script in the repository for github
3. Please keep this readme up to date
3. After you have comitted, you can tag the repository to 'build' a new version for use in actions
4After you have comitted, you can tag the repository to 'build' a new version for use in actions
6 changes: 1 addition & 5 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ async function execute() {
function getAndValidateInput() {
const slackWebhookUrl = core.getInput('slack_webhook_url', {required: true})
const message = core.getInput('message', {required: true})
let isMarkdown = core.getInput('is_markdown', {required: false})

if (!isMarkdown) {
isMarkdown = false;
}
let isMarkdown = core.getInput('is_markdown', {required: false}) === 'true'

return {
slackWebhookUrl,
Expand Down

0 comments on commit 0740890

Please sign in to comment.