Add instructions for developing with a local version of the action (#250)
This commit is contained in:
@@ -11,6 +11,11 @@ All you need to work with this project is a supported version of [Node.js](https
|
||||
|
||||
## Tasks
|
||||
|
||||
### Developing
|
||||
|
||||
Iterate quickly by developing and testing a local version of this action using `npm run local`.
|
||||
Information on setting up and configuring mocked events can be found in [`.github/workflows/local/README.md`](./workflows/local/README.md).
|
||||
|
||||
### Testing
|
||||
|
||||
When testing locally, ensure at least linting and unit tests pass by running `npm test`.
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
# Rename this file to .env and update any variables to get started
|
||||
|
||||
SLACK_BOT_TOKEN=xoxb-01010101-abcdefgh
|
||||
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/T0123456789/B0123456789/abcdefghijklmnopqrstuvwxyz
|
||||
@@ -0,0 +1,2 @@
|
||||
# Secret variables
|
||||
.env
|
||||
@@ -0,0 +1,25 @@
|
||||
# Local runs
|
||||
|
||||
For a simple development experience, a local version of this action can be used in experiments.
|
||||
|
||||
**Requirements**:
|
||||
|
||||
- An installation of [nektos/act](https://github.com/nektos/act)
|
||||
|
||||
## Configuring 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.
|
||||
|
||||
## Running an experiment
|
||||
|
||||
Run the workflow using `npm run local`. The above configurations will be used to simulate an actual workflow run.
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"pull_request": {
|
||||
"user": {
|
||||
"login": "dependabot"
|
||||
},
|
||||
"title": "Bump actions/checkout from 3 to 4",
|
||||
"html_url": "https://github.com/slackapi/slack-github-action/pull/238"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
name: Local run
|
||||
|
||||
# Requires mocking the "public" event to begin this workflow and avoid actual runs
|
||||
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows
|
||||
on:
|
||||
public:
|
||||
|
||||
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 }}
|
||||
@@ -5,6 +5,7 @@
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"local": "act public --eventpath .github/workflows/local/event.json --secret-file .github/workflows/local/.env",
|
||||
"test:mocha": "nyc mocha --config .mocharc.json test/*-test.js",
|
||||
"test": "npm run lint && npm run test:mocha",
|
||||
"build": "npx @vercel/ncc build src/index.js --license licenses.txt"
|
||||
|
||||
Reference in New Issue
Block a user