Skip to content

Commit 9e5c2fb

Browse files
workflows updated
claude review address workflow fils updated package updated comments addressed
1 parent 444ea06 commit 9e5c2fb

File tree

10 files changed

+26
-279
lines changed

10 files changed

+26
-279
lines changed

.gitattributes

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/dependabot.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

.github/workflows/actions_release.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ on:
66
tag:
77
description: "Tag for the release"
88
required: true
9-
# Uncomment if using yarn
10-
# script:
11-
# description: "Specify the build script to run"
12-
# required: true
13-
# type: string
9+
script:
10+
description: "Specify the build script to run"
11+
required: false
12+
type: string
13+
default: "npm run all"
1414

1515
permissions:
1616
contents: read
@@ -25,4 +25,5 @@ jobs:
2525
uses: step-security/reusable-workflows/.github/workflows/actions_release.yaml@v1
2626
with:
2727
tag: "${{ github.event.inputs.tag }}"
28-
# script: "${{ github.event.inputs.script }}"
28+
script: "${{ github.event.inputs.script }}"
29+

.github/workflows/audit_package.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ on:
1111
description: "Specify a base branch"
1212
required: false
1313
default: "main"
14+
script:
15+
description: "Specify the build script to run"
16+
required: false
17+
type: string
18+
default: "npm run all"
19+
1420
schedule:
1521
- cron: "0 0 * * 1"
1622

@@ -20,6 +26,7 @@ jobs:
2026
with:
2127
force: ${{ inputs.force || false }}
2228
base_branch: ${{ inputs.base_branch || 'main' }}
29+
script: ${{ inputs.script || 'npm run all' }}
2330

2431
permissions:
2532
contents: write

.github/workflows/auto_cherry_pick.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ on:
77
description: "Base branch to create the PR against"
88
required: true
99
default: "main"
10+
script:
11+
description: "Specify the build script to run"
12+
required: false
13+
type: string
14+
default: "npm run all"
1015

1116
permissions:
1217
contents: write
@@ -21,3 +26,4 @@ jobs:
2126
original-owner: "lasith-kg"
2227
repo-name: "dispatch-workflow"
2328
base_branch: ${{ inputs.base_branch }}
29+
script: ${{ inputs.script || 'npm run all' }}

.github/workflows/build-test.yml

Lines changed: 1 addition & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: 'Build and Test'
2-
on: # rebuild any PRs and main branch changes
2+
on:
33
pull_request:
44
workflow_dispatch:
55
push:
@@ -9,12 +9,6 @@ on: # rebuild any PRs and main branch changes
99
jobs:
1010
integration-tests:
1111
runs-on: ubuntu-latest
12-
permissions:
13-
contents: write
14-
actions: write
15-
env:
16-
INTEGRATION_TEST_WORKFLOW_FILE: "integration-tests.yml"
17-
INTEGRATION_TEST_WORKFLOW_ID: 64701969 # This ID Will Change On Fork
1812
steps:
1913
- uses: actions/checkout@v4
2014
- id: nvmrc
@@ -36,132 +30,3 @@ jobs:
3630
npm ci
3731
- run: |
3832
npm run all
39-
- uses: ./
40-
id: fail-ref-workflow-dispatch
41-
name: "Dispatch Workflow using workflow_dispatch Method, to a Non-existent Branch"
42-
continue-on-error: true
43-
with:
44-
dispatch-method: "workflow_dispatch"
45-
repo: "${{ github.event.repository.name }}"
46-
owner: "${{ github.repository_owner }}"
47-
ref: "non-existent-branch/${{ github.run_id }}" # This branch cannot realistically exist
48-
workflow: "${{ env.INTEGRATION_TEST_WORKFLOW_FILE }}"
49-
token: "${{ secrets.GITHUB_TOKEN }}"
50-
workflow-inputs: '{"placeholder": "placeholder"}'
51-
- uses: ./
52-
id: fail-file-workflow-dispatch
53-
name: "Dispatch Workflow using workflow_dispatch Method, to a Non-existent Workflow File"
54-
continue-on-error: true
55-
with:
56-
dispatch-method: "workflow_dispatch"
57-
repo: "${{ github.event.repository.name }}"
58-
owner: "${{ github.repository_owner }}"
59-
ref: "main"
60-
workflow: "${{ github.run_id }}.yml" # This workflow file cannot realistically exist
61-
token: "${{ secrets.GITHUB_TOKEN }}"
62-
workflow-inputs: '{"placeholder": "placeholder"}'
63-
- uses: ./
64-
id: fail-inputs-workflow-dispatch
65-
name: "Dispatch Workflow using workflow_dispatch Method, with an unsupported workflow inputs"
66-
continue-on-error: true
67-
with:
68-
dispatch-method: "workflow_dispatch"
69-
repo: "${{ github.event.repository.name }}"
70-
owner: "${{ github.repository_owner }}"
71-
ref: "main"
72-
workflow: "${{ env.INTEGRATION_TEST_WORKFLOW_FILE }}"
73-
token: "${{ secrets.GITHUB_TOKEN }}"
74-
workflow-inputs: '{"placeholder": 0}' # 0 is not a string type
75-
- id: verify-fail-workflow-dispatch
76-
name: "Verify Action Outputs for worflow-dispatch"
77-
shell: bash
78-
run: |
79-
set -euo pipefail
80-
81-
if [[ "${{ steps.fail-ref-workflow-dispatch.outcome }}" != "failure" ]]; then
82-
>&2 echo "🔴 fail-ref-workflow-dispatch step was expected to fail"; exit 1
83-
fi
84-
85-
if [[ "${{ steps.fail-file-workflow-dispatch.outcome }}" != "failure" ]]; then
86-
>&2 echo "🔴 fail-file-workflow-dispatch step was expected to fail"; exit 1
87-
fi
88-
89-
if [[ "${{ steps.fail-inputs-workflow-dispatch.outcome }}" != "failure" ]]; then
90-
>&2 echo "🔴 fail-inputs-workflow-dispatch step was expected to fail"; exit 1
91-
fi
92-
- uses: ./
93-
id: workflow-dispatch
94-
name: "Dispatch Using workflow_dispatch Method"
95-
with:
96-
dispatch-method: "workflow_dispatch"
97-
repo: "${{ github.event.repository.name }}"
98-
owner: "${{ github.repository_owner }}"
99-
ref: "refs/heads/main"
100-
workflow: "${{ env.INTEGRATION_TEST_WORKFLOW_FILE }}"
101-
token: "${{ secrets.GITHUB_TOKEN }}"
102-
workflow-inputs: |
103-
{
104-
"string-type": "placeholder",
105-
"number-type": "1",
106-
"boolean-type": "true"
107-
}
108-
- uses: ./
109-
id: repository-dispatch-custom-backoff
110-
name: "Dispatch Using repositroy_dispatch Method and custom exponential backoff parameters"
111-
with:
112-
dispatch-method: "repository_dispatch"
113-
event-type: "repository-dispatch"
114-
repo: "${{ github.event.repository.name }}"
115-
owner: "${{ github.repository_owner }}"
116-
token: "${{ secrets.GITHUB_TOKEN }}"
117-
workflow-inputs: |
118-
{
119-
"string-type": "placeholder",
120-
"nested": {
121-
"number-type": 1,
122-
"boolean-type": true
123-
}
124-
}
125-
starting-delay-ms: 150
126-
max-attempts: 3
127-
time-multiple: 1.5
128-
- uses: ./
129-
id: wait-repository-dispatch
130-
name: "Dispatch Using repository_dispatch Method And Wait For Run-ID"
131-
with:
132-
dispatch-method: "repository_dispatch"
133-
event-type: "repository-dispatch"
134-
repo: "${{ github.event.repository.name }}"
135-
owner: "${{ github.repository_owner }}"
136-
token: "${{ secrets.GITHUB_TOKEN }}"
137-
workflow-inputs: |
138-
{
139-
"string-type": "placeholder",
140-
"nested": {
141-
"number-type": 1,
142-
"boolean-type": true
143-
}
144-
}
145-
discover: true
146-
- id: verify-repository-dispatch-outcome
147-
name: Await Run ID ${{ steps.wait-repository-dispatch.outputs.run-id }}
148-
uses: codex-/await-remote-run@v1
149-
with:
150-
token: ${{ secrets.GITHUB_TOKEN }}
151-
repo: ${{ github.event.repository.name }}
152-
owner: ${{ github.repository_owner }}
153-
run_id: ${{ steps.wait-repository-dispatch.outputs.run-id }}
154-
- id: verify-repository-dispatch-outputs
155-
name: "Verify Action Outputs for repository-dispatch"
156-
shell: bash
157-
run: |
158-
set -euo pipefail
159-
160-
# wait-repository-dispatch
161-
if [[ -z "${{ steps.wait-repository-dispatch.outputs.run-id }}" ]]; then
162-
>&2 echo "🔴 wait-repository-dispatch step should output 'run-id'"; exit 1
163-
fi
164-
165-
if [[ -z "${{ steps.wait-repository-dispatch.outputs.run-url }}" ]]; then
166-
>&2 echo "🔴 wait-repository-dispatch step should output 'run-url'"; exit 1
167-
fi

.github/workflows/codeql-analysis.yml

Lines changed: 0 additions & 71 deletions
This file was deleted.

.github/workflows/integration-tests.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ There was a need for this action as currently available actions...
99
- Support the `workflow_dispatch` or `repository_dispatch` event, **but not both**
1010
- Use Run ID extraction algorithms that are either **API-intensive** or **unreliable** on repositories that experience a high velocity of workflows
1111

12-
# Acknowledgements
13-
14-
This GitHub Action is a fork of [`codex-/return-dispatch`](https://github.com/codex-/return-dispatch). This action supported the ability to extract a Run ID, but exclusively supported the `workflow_dispatch` method. I decided to fork this action as it had an intuitive code-base and excellent testing philosophy.
15-
16-
From a **compatibility** and **performance** perspective, this GitHub Action superseedes [`codex-/return-dispatch`](https://github.com/codex-/return-dispatch), as it additionally supports the `repository_dispatch` method and uses a more efficient algorithm to extract the Run ID for a dispatched workflow
17-
1812
# Usage
1913

2014
## Creating Dispatch Events
@@ -184,14 +178,14 @@ Dispatching a Workflow requires an authenticated `GITHUB_TOKEN`. The required pe
184178

185179
## Generating a `GITHUB_TOKEN`
186180

187-
There are also multiple methods of generating `GITHUB_TOKEN`. If you are dispatching a workflow from the **current repository**, a **GitHub Actions Token** would be the most secure option. If you are dispatching a workflow to a **remote repository**, I would personally recommend a **GitHub App Token**. GitHub App Tokens are ephemeral (valid for 1 hour) and have fine grained access control over permissions and repositories. Additionally they are not bound to a particular developers identity, unlike a Personal Access Token.
181+
There are also multiple methods of generating `GITHUB_TOKEN`. If you are dispatching a workflow from the **current repository**, a **GitHub Actions Token** would be the most secure option. If you are dispatching a workflow to a **remote repository**, We would personally recommend a **GitHub App Token**. GitHub App Tokens are ephemeral (valid for 1 hour) and have fine grained access control over permissions and repositories. Additionally they are not bound to a particular developers identity, unlike a Personal Access Token.
188182

189183
- Fine Grained Tokens
190184
- [GitHub Actions Token](https://docs.github.com/en/actions/security-guides/automatic-token-authentication)
191185
- [GitHub App Token](https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/making-authenticated-api-requests-with-a-github-app-in-a-github-actions-workflow)
192186
- [Personal Access Token 🆕](https://github.blog/2022-10-18-introducing-fine-grained-personal-access-tokens-for-github/)
193187
- Personal Access Tokens (Classic)
194-
- I would **strongly** advise using this as they are not as secure as it's [fine-grained replacement](https://github.blog/2022-10-18-introducing-fine-grained-personal-access-tokens-for-github/) and can potentially be configured without an expiry time.
188+
- We would **strongly** advise using this as they are not as secure as it's [fine-grained replacement](https://github.blog/2022-10-18-introducing-fine-grained-personal-access-tokens-for-github/) and can potentially be configured without an expiry time.
195189

196190
The below table shows the neccessary permissions for all the unique combinations of these factors. If using a Fine Grained Token, ensure that the permissions correspond to the repository that contains the workflow you are attempting to dispatch.
197191

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,18 @@
1111
"lint": "eslint src/**/*.ts",
1212
"package": "ncc build --source-map --license licenses.txt",
1313
"test": "jest",
14-
"all": "npm run build && npm run format && npm run lint && npm run package && npm test",
15-
"release": "release-it"
14+
"all": "npm run build && npm run format && npm run lint && npm run package && npm test"
1615
},
1716
"repository": {
1817
"type": "git",
19-
"url": "git+https://github.com/lasithkoswattagamage/dispatch-workflow.git"
18+
"url": "git+https://github.com/step-security/dispatch-workflow.git"
2019
},
2120
"keywords": [
2221
"actions",
2322
"node",
2423
"setup"
2524
],
26-
"author": "",
25+
"author": "step-security",
2726
"license": "MIT",
2827
"dependencies": {
2928
"@actions/core": "^1.10.1",

0 commit comments

Comments
 (0)