Skip to content

Commit bfa5cbd

Browse files
committed
docs: add docsite to repository (closes #2)
1 parent 1a9ff6f commit bfa5cbd

21 files changed

+897
-1
lines changed

.github/workflows/docs.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: docs
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- main
7+
permissions:
8+
contents: write
9+
jobs:
10+
deploy:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Configure Git Credentials
15+
run: |
16+
git config user.name github-actions[bot]
17+
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
18+
- uses: actions/setup-python@v5
19+
with:
20+
python-version: 3.x
21+
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
22+
- uses: actions/cache@v4
23+
with:
24+
key: mkdocs-material-${{ env.cache_id }}
25+
path: .cache
26+
restore-keys: |
27+
mkdocs-material-
28+
- run: pip install mkdocs mkdocs-terminal mkdocs-git-revision-date-plugin 'mkdocs-spellcheck[symspellpy]' mkdocs-llmstxt mkdocs-rss-plugin mkdocs-ultralytics-plugin
29+
- run: mkdocs gh-deploy --force

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
node_modules
22
coverage
3-
.env
3+
.env
4+
.DS_Store
5+
.site
6+
site
7+
.cache

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- [setting up x api credentials](#setting-up-x-api-credentials)
2020
- [development](#development)
2121
- [contributing](#contributing)
22+
- [documentation](#documentation)
2223
- [support this project](#-support-this-project)
2324
- [license](#license)
2425

@@ -201,6 +202,21 @@ contributions are welcome! here's how you can help:
201202

202203
please make sure your code passes all tests and follows the project's coding style.
203204

205+
## 📚 documentation
206+
207+
comprehensive documentation for this project is available on our dedicated documentation site at [https://captradeoff.github.io/x-post-action/](https://captradeoff.github.io/x-post-action/). the site is built using the [d-sys-wiki documentation template](https://github.com/captradeoff/d-sys-wiki-documentation-template).
208+
209+
the documentation includes:
210+
- detailed usage instructions
211+
- api reference
212+
- configuration options
213+
- examples and tutorials
214+
- troubleshooting guides
215+
216+
the documentation source files are located in the `docs/` directory of this repository. you can contribute to the documentation by submitting pull requests to update these files.
217+
218+
visit the documentation site to learn more about how to effectively use this action in your workflows.
219+
204220
## ⭐ support this project
205221

206222
if you find this project useful, please consider:

docs/credentials.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# 🔑 setting up x api credentials
2+
3+
to use the x post action, you'll need to set up a developer account and create an app on x.
4+
5+
## step 1: create a developer account
6+
7+
1. go to the [x developer portal](https://developer.twitter.com/en/portal/dashboard)
8+
2. sign in with your x account
9+
3. apply for a developer account if you don't already have one
10+
11+
## step 2: create a new app
12+
13+
1. in the developer portal, navigate to "projects & apps"
14+
2. click "create app"
15+
3. fill in the required information about your app
16+
4. set the app permissions to "read and write"
17+
18+
## step 3: generate access tokens
19+
20+
1. from your app's dashboard, navigate to the "keys and tokens" tab
21+
2. generate consumer keys (app key and app secret)
22+
3. generate access token and access token secret
23+
24+
## step 4: add credentials to github secrets
25+
26+
1. in your github repository, go to settings > secrets and variables > actions
27+
2. click "new repository secret"
28+
3. add the following secrets:
29+
- `X_APP_KEY`: your app key
30+
- `X_APP_SECRET`: your app secret
31+
- `X_ACCESS_TOKEN`: your access token
32+
- `X_ACCESS_SECRET`: your access token secret
33+
34+
## step 5: use secrets in your workflow
35+
36+
reference the secrets in your workflow file:
37+
38+
```yaml
39+
- name: post to x
40+
uses: captradeoff/x-post-action@v1
41+
with:
42+
appKey: ${{ secrets.X_APP_KEY }}
43+
appSecret: ${{ secrets.X_APP_SECRET }}
44+
accessToken: ${{ secrets.X_ACCESS_TOKEN }}
45+
accessSecret: ${{ secrets.X_ACCESS_SECRET }}
46+
message: 'hello from github actions!'
47+
```
48+
49+
## troubleshooting credentials
50+
51+
if you encounter authentication issues:
52+
53+
1. verify that all four credentials are correctly stored in github secrets
54+
2. ensure your app has "read and write" permissions
55+
3. check that your access tokens haven't expired
56+
4. make sure your developer account is in good standing
57+
5. verify that you haven't exceeded rate limits

docs/description.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# 📝 description
2+
3+
this action allows you to automatically post messages to x from your github workflow.
4+
5+
it can be used to announce new releases, share updates, or integrate your github workflow with x communities.
6+
7+
## what it does
8+
9+
the x post action simplifies the process of posting to x (formerly twitter) directly from your github workflows. using the twitter api v2, this action enables automated social media updates whenever significant events occur in your repository.
10+
11+
## use cases
12+
13+
- announce new software releases with version information
14+
- share project updates, milestones and achievements
15+
- notify your audience about bug fixes and important patches
16+
- build an engaged community around your open source project
17+
- integrate your development pipeline with social media outreach

docs/development/contributing.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# 🤝 contributing
2+
3+
contributions are welcome! this page explains how you can help improve the x post action.
4+
5+
## ways to contribute
6+
7+
there are many ways to contribute to this project:
8+
9+
- report bugs and suggest features through issues
10+
- fix bugs and implement new features
11+
- improve documentation
12+
- write tests
13+
- share the project with others
14+
15+
## contribution workflow
16+
17+
1. **fork the repository**: click the fork button at the top of the [repository page](https://github.com/captradeoff/x-post-action)
18+
2. **create a feature branch**: `git checkout -b feature/your-feature-name`
19+
3. **make your changes**: implement your feature or fix
20+
4. **write or update tests**: ensure your code is well-tested
21+
5. **ensure tests pass**: run `npm test` to make sure everything works
22+
6. **build the action**: run `npm run build` to update the dist folder
23+
7. **commit your changes**: `git commit -m 'add some feature'`
24+
8. **push to the branch**: `git push origin feature/your-feature-name`
25+
9. **open a pull request**: go to your fork on github and click the 'new pull request' button
26+
27+
## pull request guidelines
28+
29+
when submitting a pull request:
30+
31+
- fill in the required template
32+
- add a clear title and description
33+
- reference any relevant issues
34+
- include screenshots and animated gifs if appropriate
35+
- ensure all tests are passing
36+
- make sure you've built the action with `npm run build`
37+
38+
## code style
39+
40+
please make sure your code follows the project's coding style:
41+
42+
- use camelCase for variable and function names
43+
- include jsdoc comments for functions
44+
- keep functions small and focused
45+
- use meaningful variable names
46+
- add appropriate error handling
47+
48+
## ⭐ supporting the project
49+
50+
if you find this project useful, please consider:
51+
52+
- ⭐ starring the repository on github
53+
- 🔄 forking the repository to contribute
54+
- 📢 sharing the project with others who might find it helpful
55+
- 🐛 reporting bugs or suggesting features through issues
56+
- 💻 submitting pull requests to improve the code or documentation
57+
58+
your support helps maintain and improve this project!
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# 💻 development
2+
3+
this project uses node.js and the twitter api v2 client.
4+
5+
## prerequisites
6+
7+
before you begin, ensure you have:
8+
9+
- node.js (v20 recommended)
10+
- npm
11+
- git
12+
- x developer account and api credentials
13+
14+
## setting up local development
15+
16+
1. clone the repository:
17+
```bash
18+
git clone https://github.com/captradeoff/x-post-action.git
19+
cd x-post-action
20+
```
21+
22+
2. install dependencies:
23+
```bash
24+
npm install
25+
```
26+
27+
3. for testing with actual api calls, create a `.env` file:
28+
```bash
29+
cp .env.sample .env
30+
```
31+
32+
4. edit the `.env` file to add your x api credentials
33+
34+
## project structure
35+
36+
- `index.js`: main entry point
37+
- `action.yaml`: github action definition
38+
- `index.test.js`: unit tests
39+
- `integration.test.js`: api integration tests
40+
- `integration-action.test.js`: action function tests
41+
- `dist/`: compiled action code
42+
43+
## building the action
44+
45+
the action uses @vercel/ncc to compile the node.js code and dependencies into a single file:
46+
47+
```bash
48+
npm run build
49+
```
50+
51+
this will create a `dist/index.js` file that is referenced in `action.yaml`.
52+
53+
## development workflow
54+
55+
1. make changes to the code
56+
2. update or add tests to cover your changes
57+
3. run tests to ensure everything works:
58+
```bash
59+
npm test
60+
```
61+
4. build the action:
62+
```bash
63+
npm run build
64+
```
65+
5. commit and push your changes
66+
6. create a pull request

docs/development/testing.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# testing
2+
3+
this project uses jest for testing with both unit tests and integration tests.
4+
5+
## unit tests
6+
7+
the unit tests mock the twitter api and github actions core module to verify functionality without making actual api calls.
8+
9+
to run the unit tests:
10+
11+
```bash
12+
npm test
13+
```
14+
15+
this will run all test files matching `*.test.js` in the project root.
16+
17+
coverage report is generated automatically when running the tests. you can view the html coverage report in the `coverage` directory.
18+
19+
## integration tests
20+
21+
integration tests make actual calls to the x api to verify real-world functionality.
22+
23+
### setup for integration tests
24+
25+
1. copy the `.env.sample` file to `.env` and fill in with your x api credentials:
26+
```bash
27+
cp .env.sample .env
28+
```
29+
30+
2. edit the `.env` file and replace placeholders with your actual api keys and tokens:
31+
```
32+
X_APP_KEY=your_actual_app_key
33+
X_APP_SECRET=your_actual_app_secret
34+
X_ACCESS_TOKEN=your_actual_access_token
35+
X_ACCESS_SECRET=your_actual_access_secret
36+
```
37+
38+
### running integration tests
39+
40+
there are several integration test scripts available:
41+
42+
```bash
43+
# run direct api integration test
44+
npm run test:integration
45+
46+
# run action function integration test
47+
npm run test:integration-action
48+
49+
# run all integration tests
50+
npm run test:integration-all
51+
```
52+
53+
### integration test details
54+
55+
the integration tests include:
56+
57+
- **direct api test**: tests the x api directly using credentials from .env
58+
- **action function test**: tests the postTweet function exported from index.js
59+
60+
both tests will:
61+
- post actual tweets to your x account
62+
- include extensive logging for debugging
63+
- skip tests automatically if environment variables aren't set
64+
- add a timestamp to make each test message unique
65+
66+
**note:** be careful with integration tests as they make real api calls and will post actual tweets to your account.

0 commit comments

Comments
 (0)