Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: wrap payloads to send to a "method" with "token" or "webhook" #333

Open
wants to merge 106 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
959992e
feat!: wrap payloads to send to a "method" with "token" or "webhook"
zimeg Jul 18, 2024
82bbd29
docs(fix): remove an extra trailing closing brace
zimeg Aug 30, 2024
c8916a0
fix: remove milliseconds from the returned epoch time
zimeg Aug 30, 2024
efe707e
feat: log the entire error stack for easier debugs
zimeg Aug 30, 2024
c2d4e9c
build: remove compilation steps from the local build
zimeg Aug 30, 2024
1da745b
test(fix): resolve the posted webhook with placeholder values
zimeg Aug 30, 2024
09a1d45
ci: include chat.postMessage and files.uploadV2 in local tests
zimeg Aug 30, 2024
b8e82b8
ci: include static checks of code as part of ci
zimeg Aug 30, 2024
962e0db
fix: debug actual response data from the webhook
zimeg Aug 30, 2024
dbdbf9f
docs: include a few more words about action outputs
zimeg Aug 30, 2024
a10e1f7
fix: use the 'channel' in responses as 'channel_id'
zimeg Aug 30, 2024
9fb3e9e
build(fix): remove removed files from the jsdocs
zimeg Aug 30, 2024
57ab9a4
refactor: parse payload content in a new "content" module
zimeg Aug 30, 2024
6ca6013
style: remove extra spacing from the pull request template
zimeg Aug 30, 2024
5875c61
fix: remove addtional error logging from erroring inputs
zimeg Aug 30, 2024
5b4b7b8
feat: parse action payload inputs as possible yaml values
zimeg Aug 30, 2024
ee9e200
docs: update examples and wordings to use the latest changes
zimeg Aug 30, 2024
4c57022
test: update tests in ci to use the yaml inputs
zimeg Aug 30, 2024
72734a9
feat: increase methods for quick use in the local workflow
zimeg Aug 30, 2024
4fa18f2
ci(temp): use the changes of the pull request when running tests
zimeg Aug 30, 2024
32c4ddb
ci: workaround broken biome installations in ci
zimeg Aug 30, 2024
5ffcbc8
ci(fix): remove additional steps for checking test coverage
zimeg Aug 30, 2024
0d8d929
fix: avoid setting setting secrets twice for possible missing values
zimeg Aug 31, 2024
e7f7020
docs: reference the complete 'incoming webhooks' feature
zimeg Sep 25, 2024
7f42936
docs: replace the link to repo secrets with another page
zimeg Sep 25, 2024
78e74e6
feat: require a webhook type as part of webhook inputs
zimeg Sep 25, 2024
31b6ed1
feat: open the option to templatize input payloads to action input st…
zimeg Sep 25, 2024
5f3b855
feat: link the outputs of the action to log streams of the webapi
zimeg Sep 25, 2024
bc9c18b
fix: link without spacing when creating noop functions
zimeg Sep 25, 2024
8c35f78
ci(fix): use the original message timestamp when threading a message
zimeg Sep 25, 2024
b1453da
fix: use a stringified thread ts to avoid float madness
zimeg Sep 25, 2024
518946d
test: templatize the payload file inputs for variable replacements
zimeg Sep 26, 2024
1a77eed
refactor: move tests into a test directory and away from src
zimeg Sep 26, 2024
eea2eb1
fix: avoid debug logging undefined data of an undefined response
zimeg Sep 26, 2024
38b6f1e
style: lint fixes that are required for ci to pass
zimeg Sep 26, 2024
e3f0238
docs: polish and findings from past readings of the readme
zimeg Sep 26, 2024
7aee130
fix: correct webclient proxy warning to be the https axios agent
zimeg Sep 27, 2024
abda089
fix: use the nested message response to gather thread ts
zimeg Sep 27, 2024
6b14b32
test: fail tests that are expected to have thrown but dont
zimeg Sep 27, 2024
23913a6
test: confirm requests are sent with arguments to the slack web api
zimeg Sep 27, 2024
92fd8d8
fix: include the time of action completion when erroring too
zimeg Sep 27, 2024
856cb18
chore: setup a manifest app with workflow and scopes and webhooks
zimeg Sep 28, 2024
3d0eb1e
docs: improve setup instructions with more correct wordings
zimeg Sep 28, 2024
28dee88
ci: revert removal of the build step for packaged distribution
zimeg Sep 30, 2024
a9b40ba
build: include the source map in build outputs for error debugs
zimeg Sep 30, 2024
29c7ea6
ci(chore): run check ups of the health score on changes
zimeg Sep 30, 2024
1a8d212
ci(fix): include the include of included paths of check up
zimeg Sep 30, 2024
01ca583
revert(ci): oh oops the error is from codecov setups in this pr
zimeg Sep 30, 2024
b88b87a
refactor: rename the testing workflow into a single test file
zimeg Sep 30, 2024
6f23616
refactor: move the local workflow into a development area
zimeg Sep 30, 2024
815c519
style: format json with separate spacing for individual array items
zimeg Sep 30, 2024
8003d03
test: confirm changes match between develop and test and docs
zimeg Oct 1, 2024
19c1ee5
ci: fix inputs that didnt match changes made in the last commit
zimeg Oct 1, 2024
ecb8404
ci: fix the path to slack resources to be in slack paths
zimeg Oct 1, 2024
0777d30
ci: fix the gathered thread ts to be from another threaded message
zimeg Oct 1, 2024
574e5f9
test: ensure a file can be uploaded from the action too
zimeg Oct 1, 2024
a10a047
style: format the incoming webhook blocks to read inline
zimeg Oct 1, 2024
3abfdb6
style: write emojis at the start of lines for consistency
zimeg Oct 1, 2024
7c719bb
chore: merge wo conflicts in upstream main
zimeg Oct 1, 2024
7165edc
ci: react to with a method before testing incoming message
zimeg Oct 2, 2024
504fb31
fix: use the config input proxy to set the webhook proxy
zimeg Oct 2, 2024
72d552d
test: remove console logs from output when test succeeds
zimeg Oct 2, 2024
9645097
chore: merge w main and the changes to health score
zimeg Oct 2, 2024
84c034a
fix: include proxied https urls with the web client methods
zimeg Oct 2, 2024
67471c1
test: confirm retries happen at expected intervals for the client
zimeg Oct 2, 2024
c711234
test: ensure errors happen during invalid config setup
zimeg Oct 2, 2024
4c6260b
fix: templatize payload content from all input sources
zimeg Oct 3, 2024
1b4979e
test: setup the same input before each test before each test
zimeg Oct 3, 2024
48d4ccf
test: match naming of spec its for more reasoning
zimeg Oct 3, 2024
16ea7d7
test: check for replacements of templatized variables
zimeg Oct 3, 2024
05b1c7c
chore: replace hardcoding types with an upstream alternative
zimeg Oct 3, 2024
8618c4d
test: confirm the expected techniques work as expected
zimeg Oct 3, 2024
8066bf9
test: confirm errors are returned when missing webhook inputs
zimeg Oct 3, 2024
103ae85
fix: use the built distribution files when running this action
zimeg Oct 3, 2024
be37553
docs: make it clear that the unix epoch is returned in time
zimeg Oct 3, 2024
75d7165
chore: remove additional type roots from past compilation
zimeg Oct 3, 2024
bc887ca
build: include the markup-js types as a development depenency
zimeg Oct 3, 2024
90d5d06
style: remove additional undefined chaining after an initial definito…
zimeg Oct 3, 2024
12e1625
docs(fix): add a step for showing the revealed credetials
zimeg Oct 15, 2024
c3a19f3
docs: include complete example links in the ci workflow variable values
zimeg Oct 15, 2024
e909226
build: set the node version to match the runner runtime
zimeg Oct 15, 2024
a2b32d6
docs(fix): tyypo reminants -> remnants
zimeg Oct 15, 2024
6075734
docs: give the action context for the github context
zimeg Oct 15, 2024
8be2d3a
docs: locate secret values from either outputs or the app settings
zimeg Oct 17, 2024
fa91f44
docs: include the requirement of a channel ID where the bot is added
zimeg Oct 17, 2024
540f02d
docs: include an overview of the app found in resources for development
zimeg Oct 17, 2024
c21fea2
build: include an example environment variable file for testing
zimeg Oct 17, 2024
a8affaa
docs: reference the resources for testing experimental changes in dev…
zimeg Oct 17, 2024
2133481
docs(style): wrap lines that exceed the length of the deno fmt
zimeg Oct 17, 2024
fd5313b
docs: make wording of step setups more percise
zimeg Oct 17, 2024
da7d2a1
docs: revert the changed title to that of the original readme
zimeg Oct 18, 2024
7816a2c
docs(fix): replace a redirected link to contextual workflow info
zimeg Oct 18, 2024
ad5d399
temp: print the octokit context in a pull request setting
zimeg Oct 18, 2024
a7dc253
docs: fix the context of the default github event payload
zimeg Oct 21, 2024
23838b2
docs: introduce concepts of sending variables with more context
zimeg Oct 21, 2024
aab5451
docs: reword the exampliary sentance to reference 'action'
zimeg Oct 21, 2024
aceca25
docs(fix): remove the json requirement from input payloads
zimeg Oct 21, 2024
b773f12
docs(style): include a few more words for easier reading
zimeg Oct 21, 2024
e0e254b
revert "temp: print the octokit context in a pull request setting"
zimeg Oct 21, 2024
e37146c
docs: link to outbound resources with more information
zimeg Oct 22, 2024
9df54bb
docs: include more explicit detail on which workflow is updated
zimeg Oct 22, 2024
e80e77b
docs: quick link to the sections of different techniques
zimeg Oct 22, 2024
99dd6aa
docs: include information on the reason for deliminating payloads
zimeg Oct 22, 2024
ac9a37e
docs(style): change a few words for spacing setups
zimeg Oct 22, 2024
f19da83
docs(fix): recommend a templated variable found in the octokit payload
zimeg Oct 22, 2024
9bc0ad9
docs(fix): wrap a numeric float in quotations to make it a string
zimeg Oct 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .c8rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"include": ["src/*.js"],
"exclude": ["**/*.spec.js"],
"reporter": ["lcov", "text"],
"all": false,
"cache": true
}
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

132 changes: 0 additions & 132 deletions .eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### Summary
### Summary

Describe the goal of this PR. Mention any related Issue numbers.

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/local/.env.example
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The concept of a local workflow is now moved between develop.yml and the files in .github/resources πŸ‘οΈβ€πŸ—¨οΈ

Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Rename this file to .env and update any variables to get started

SLACK_BOT_TOKEN=xoxb-01010101-abcdefgh
SLACK_CHANNEL_ID=C0123456789
SLACK_USER_TOKEN=xoxp-22222222-example
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/T0123456789/B0123456789/abcdefghijklmnopqrstuvwxyz
47 changes: 40 additions & 7 deletions .github/workflows/local/README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,58 @@
# Local runs

For a simple development experience, a local version of this action can be used in experiments.
For a simple development experience, a local version of this action can be used
in experiments:

```sh
$ npm run local # Test techniques
```

**Requirements**:

- An installation of [nektos/act](https://github.com/nektos/act)
- A running instance of [Docker](https://www.docker.com)

## Setting up an app

The saved `local.yml` workflow uses `webhook` and `method` for a combination of
features, which expects the following scopes:

- `chat:write`
- `files:write`
- `reactions:write`

## Configuring secrets
These scopes aren't required if the methods used change, but others might be if
different API methods are called!

To use `${{ secrets.* }}` in the workflow, move `.env.example` to `.env` and update any variables.
This app will have useful variables that can be configured as values in this
next section.

## Mocking event payloads
## Configuring values

Different event payloads can be mocked directly with changes to the `event.json` file.
### Changing secrets

To use `${{ secrets.* }}` in the workflow, move `.env.example` to `.env` and
update any variables.

### Mocking event payloads

Different event payloads can be mocked directly with changes to the `event.json`
file.

Reference: https://docs.github.com/en/webhooks/webhook-events-and-payloads

## Updating the workflow

The `local.yml` file contains the workflow used for testing. Updates to these steps can be made to test various functionalities.
The `local.yml` file contains the workflow used for testing. Updates to these
steps can be made to test various functionalities.

## Running an experiment

Run the workflow using `npm run local`. The above configurations will be used to simulate an actual workflow run.
Run the workflow using `act` with the `npm run local` script. The above settings
will be used to simulate an actual workflow run:

```sh
$ npm run local
...
[Local run/run] 🏁 Job succeeded
```
92 changes: 75 additions & 17 deletions .github/workflows/local/local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,78 @@ jobs:
run:
runs-on: ubuntu-latest
steps:
- name: Checkout action
uses: actions/checkout@v4
- name: Build action
run: npm install && npm run build
- name: Send a message into channel
id: slack
uses: ./.
with:
payload: |
{
"repository": "${{ github.repository }}",
"pull_request_username": "${{ github.event.pull_request.user.login }}",
"pull_request_title": ${{ toJSON(github.event.pull_request.title) }},
"pull_request_url": "${{ github.event.pull_request.html_url }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- name: Checkout action
uses: actions/checkout@v4
- name: Build action
run: npm install
- name: Post a webhook message into channel
id: webhook
uses: ./.
with:
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
payload: |
repository: ${{ github.repository }}
pull_request_username: ${{ github.event.pull_request.user.login }}
pull_request_title: ${{ toJSON(github.event.pull_request.title) }}
pull_request_url: ${{ github.event.pull_request.html_url }}
- name: Post a token message into channel
id: api
uses: ./.
with:
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
channel: ${{ secrets.SLACK_CHANNEL_ID }}
text: "Action happens at <https://github.com/${{ github.repository }}>"
- name: Upload this workflow file
id: file
uses: ./.
with:
method: files.uploadV2
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
channel_id: ${{ secrets.SLACK_CHANNEL_ID }}
initial_comment: "This code exists here"
file: .github/workflows/local/local.yml
filename: action.yml
- name: Initiate the deployment sequence
id: slack
uses: ./.
with:
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
channel: ${{ secrets.SLACK_CHANNEL_ID }}
text: "Deployment started :eyes:"
attachments:
- color: "dbab09"
fields:
- title: "Status"
short: true
value: "In Progress"
- name: Countdown
run: sleep 10
- name: Launch time is now
uses: ./.
with:
method: chat.update
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
channel: ${{ secrets.SLACK_CHANNEL_ID }}
ts: "${{ steps.slack.outputs.ts }}"
text: "Deployment finished :rocket:"
attachments:
- color: "28a745"
fields:
- title: "Status"
short: true
value: "Completed"
- name: Celebrate wins
uses: ./.
with:
method: reactions.add
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
channel: ${{ secrets.SLACK_CHANNEL_ID }}
timestamp: ${{ steps.slack.outputs.ts }}
name: "tada"
Loading
Loading