-
Notifications
You must be signed in to change notification settings - Fork 45
Update and rename GITHUB_TOKEN_SETUP #441
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
Open
ezequiel-rodriguez
wants to merge
2
commits into
feature/changelog
Choose a base branch
from
ghAppUpdate
base: feature/changelog
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| # GitHub App Setup for Changelog Page | ||
|
|
||
| The Changelog page (`/changelog`) fetches release data from multiple GitHub repositories using the GitHub REST API. What you need to do here is configure your own repository so it can push updates to the Devportal using the GitHub App. | ||
|
|
||
| ## Overview | ||
|
|
||
| _From your repository:_ | ||
|
|
||
| 1. A GitHub Actions workflow is triggered on an Approval event. | ||
| 2. The workflow: | ||
| - Generates a GitHub App installation token. | ||
| - Clones the rsksmart/devportal repository using that token. | ||
| - Transforms your local file(s) into the format/layout expected by the Devportal. | ||
| -- Commits and pushes a branch to rsksmart/devportal. | ||
| -- Creates a Pull Request in rsksmart/devportal. | ||
| 3. Once the PR is merged, the Devportal `/changelog` page reflects the new content. | ||
|
|
||
| Everything is done through the GitHub App. | ||
|
|
||
| ## Prerequisites | ||
| The GitHub App must be installed in rsksmart and have access to: | ||
| * DevPortal repository (target) | ||
| * Your repository (source) | ||
|
|
||
| ## Setup Instructions | ||
|
|
||
| ### 1. What You Must Configure to Allow the GitHub App to Push Changelog Updates | ||
|
|
||
| #### Add the App Credentials as GitHub Actions Secrets | ||
|
|
||
| In the repo running the workflow add: | ||
|
|
||
| **Required Secrets:** | ||
| | Secret | Value | | ||
| | ------------------------ | ------------------------------------- | | ||
| | `GH_APP_ID` | The App ID | | ||
| | `GH_APP_PRIVATE_KEY` | The content of the private key `.pem` | | ||
| | `GH_APP_INSTALLATION_ID` | Installation ID for the repository | | ||
|
|
||
| These are consumed by your GitHub Actions workflow. | ||
|
|
||
| _Disclaimer: Create a ticket for the security team in order to fill in the values for the required secrets._ | ||
|
|
||
| ### 2. How the Workflow Uses the GitHub App Token | ||
|
|
||
| Your workflow needs to include: | ||
|
|
||
| ```bash | ||
| # Step 1: Generate GitHub App Token | ||
| - name: Generate GitHub App Token | ||
| id: generate_token | ||
| uses: actions/create-github-app-token@31c86eb3b33c9b601a1f60f98dcbfd1d70f379b4 # v1.10.3 | ||
| with: | ||
| app-id: ${{ secrets.GH_APP_ID }} | ||
| private-key: ${{ secrets.GH_APP_PRIVATE_KEY }} | ||
| owner: rsksmart | ||
| repositories: devportal | ||
|
|
||
| # Step 2: Clone the Devportal Repository | ||
| - name: Clone Devportal Repository | ||
| run: | | ||
| TIMESTAMP=$(date +'%Y%m%d-%H%M%S') | ||
| BRANCH_NAME="update-from-foundry-starter-${TIMESTAMP}" | ||
| echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV | ||
|
|
||
| git clone https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/rsksmart/devportal.git | ||
| cd devportal | ||
| git checkout -b ${BRANCH_NAME} || git checkout ${BRANCH_NAME} | ||
| cd .. | ||
| ``` | ||
|
|
||
| Step 1 automatically generates an installation token with the correct permissions and Step 2 uses it. | ||
|
|
||
| The workflow then: | ||
|
|
||
| - clones the repository using x-access-token:<token> | ||
| - pushes commits | ||
| - creates pull requests via GitHub API | ||
|
|
||
|
|
||
| ## Verification | ||
|
|
||
| 1. Navigate to `/changelog` page | ||
| 2. If configured correctly, you should see live GitHub release data | ||
| 3. If not configured, you'll see a message: "Using sample data due to GitHub API rate limits. Add a GitHub token for live data." | ||
|
|
||
| ## Security Notes | ||
|
|
||
| - **Never commit the private key (.pem) to version control** | ||
| - The `.env.local` file is already in `.gitignore` | ||
| - Restrict repository access during GitHub App installation | ||
| - Rotate tokens periodically for security | ||
| - Installation tokens generated from the app are short-lived (1 hour), increasing security | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### Still seeing sample data after setup? | ||
|
|
||
| 1. Verify the GitHub Actions Secrets are created and security added the corresponding values: | ||
| - `GH_APP_ID` | ||
| - `GH_APP_PRIVATE_KEY` | ||
| - `GH_APP_INSTALLATION_ID` | ||
| 2. Restart your development server completely | ||
| 3. Check browser console for any API errors | ||
| 4. Try the quick testing method above | ||
| 5. Ensure the app is installed on the correct GitHub organization or repositories | ||
| 6. Confirm the private key is correctly formatted | ||
|
|
||
|
|
||
| ### Rate limiting issues? | ||
|
|
||
| - Confirm the GitHub App is being used and token generation is working | ||
| - Check that you're not making excessive requests | ||
| - Consider implementing caching for production use | ||
|
|
||
| ## Repositories Monitored | ||
|
|
||
| The changelog page fetches data from these Rootstock repositories: | ||
|
|
||
| - `rsksmart/rskj` (RSKj) | ||
| - `rsksmart/rsk-cli` (Rootstock CLI) | ||
| - `rsksmart/rsk-explorer-api` (Rootstock Explorer) | ||
| - `rsksmart/2wp-app` (Two Way Peg App) | ||
| - `rsksmart/rbtc-faucet` (Faucet) | ||
| - `rsksmart/powpeg-node` (PowPeg node) | ||
|
|
||
| All repositories are public and don't require special permissions. | ||
|
|
||
| ## API Configuration | ||
|
|
||
| The changelog page uses the following GitHub API configuration: | ||
|
|
||
| - **API Version**: `2022-11-28` (specified via `X-GitHub-Api-Version` header) | ||
| - **Releases per Repository**: 30 releases fetched per repository | ||
| - **Total Requests**: 6 repositories × 1 request each = 6 API requests per page load | ||
| - **Rate Limit Impact**: With authentication, this uses only 6 out of 5,000 hourly requests | ||
|
|
||
| ## Enhanced Features | ||
|
|
||
| The changelog page includes several enhanced features: | ||
|
|
||
| - **Smart Link Parsing**: Automatically converts plain URLs in release descriptions to clickable links | ||
| - **New Tab Links**: All links in release descriptions open in new tabs for better user experience | ||
| - **MDX Rendering**: Release descriptions support full markdown formatting | ||
| - **Responsive Design**: Optimized for all screen sizes with filtering and sorting capabilities | ||
| - **Infinite Scroll**: Loads more releases automatically as you scroll | ||
| - **Error Handling**: Graceful fallback to sample data when API limits are reached | ||
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, how about adding new repositories to the changelog? We just update the workflow with the repo URL right?