https://github.com/link-/simple-action
A very simple GitHub action implementing the command design pattern
https://github.com/link-/simple-action
Last synced: 3 months ago
JSON representation
A very simple GitHub action implementing the command design pattern
- Host: GitHub
- URL: https://github.com/link-/simple-action
- Owner: Link-
- License: mit
- Created: 2021-04-04T21:00:10.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2022-05-18T14:45:27.000Z (over 3 years ago)
- Last Synced: 2025-06-11T15:20:21.632Z (7 months ago)
- Language: JavaScript
- Size: 12.1 MB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# simple-action
> A very simple GitHub action implementing the command design pattern
## Context post
This repository is an example action adopting the design pattern discussed in this blog post: [Adopting the command design pattern for GitHub Actions](https://blog.bassemdy.com/2021/04/05/github/actions/design-patterns/command/best-practices/adopt-command-pattern-for-actions.html)
## Usage
### Workflow setup
If you introduce changes to the action, **don't forget to build**! The action's entry point is `dist/index.js` not `src/cli.js`. You can trigger a build by running: `npm run build`.
```yaml
name: Test Workflow
on:
workflow_dispatch:
jobs:
FirstJob:
runs-on: ubuntu-latest
steps:
# Because the action is hosted in this same repository and it has not
# been published to the marketplace, we have to checkout the repo
# so that we can call the local action in the next steps
- name: Checkout repository
uses: actions/checkout@v2
# Using the location action we pass the needed parameters and provide
# the name of the command to call
- name: "Get Issue Details Command"
id: get_issue_details
uses: ./
with:
command: get_issue_details
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: 1
org: TEST_ORG
repo: ${{ github.event.repository.name }}
# Same as the previous step with different parameters supplied
- name: "Get Comments Command"
id: get_comments
uses: ./
with:
command: get_comments
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: 5
# Print output from both steps
- name: "Print results"
run: |
echo ${{ steps.get_issue_details.outputs.result }}
echo ${{ steps.get_comments.outputs.result }}
```
## License
- [MIT License](./LICENSE)