Skip to content
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

Feature/commit config from UI #1413

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Musubi42
Copy link

@Musubi42 Musubi42 commented Dec 17, 2023

Musubi42 Medium Musubi42 /FEATURE/Commit-config-from-ui → Lissy93/dashy Commits: 4 | Files Changed: 4 | Additions: 158 🚫 Merge Conflicts Powered by Pull Request Badge

Category:

Feature

Overview

A button to commit the config file to Github. With a CD from the Netlify or other hosting platform, automatically trigger a rebuild, so your Dashy stay up to date.
It's a PoC has I have to manually add those variables directly in the code.
If the PoC is validated, I could Integrate the OAuth2 workflow directly in Dashy.

const accessToken = '<YOUR_ACCESS_TOKEN>';
const repoName = 'Musubi42/dashy-commit-config-from-ui';  // Change by your repo name
const filePath = 'public/conf.yml';  // Change by config file you want to update

How to generate an access token

Step 1: Register a New GitHub OAuth Application

  1. Go to GitHub Settings: Log into your GitHub account, navigate to your settings.
  2. Register a New OAuth App: Go to "Developer settings" → "OAuth Apps" → "New OAuth App".
  3. Fill in the Application Details:
    • Application Name: Choose a name for your application.
    • Homepage URL: You can use a placeholder, it doesn't matter for the PoC purpose.
    • Application Description: Optional.
    • Authorization Callback URL: This is where you will be sent after successful authentication. For local testing, use http://localhost.
  4. Register Application: Click the "Register application" button.
  5. Note Client ID and Secret: Once registered, you'll be provided with a client ID and client secret. Keep these confidential.

Step 2: Get your access token

  1. Complete this URL to get the code for the OAuth2 process.
    Paste this URL to any browser, follow the instruction.
    The repo scope allows your app to access private repositories. If you only need access to public repositories, use public_repo.
https://github.com/login/oauth/authorize?client_id=YOUR_CLIENT_ID&scope=repo

Once you have completed it, from the URL you should get the code

http://localhost/?code=<YOUR_CODE>
  1. Exchange Code for an Access Token: Make a POST request to
https://github.com/login/oauth/access_token

with the following parameters:

  • client_id: Your app's client ID.
  • client_secret: Your app's client secret.
  • code: The code you get from the previous URL

Receive the Access Token: GitHub responds with the access token, which you can use to authenticate API requests.

Screenshot

Has it is a proposition, I have replaced the button "Save to Disk", by "Commit to Github"
Add button Commit config to Github

Code Quality Checklist

  • All changes are backwards compatible
  • All lint checks and tests are passing
  • There are no (new) build warnings or errors
  • Bumps version, if new feature added (V2.1.1 -> V2.2.0)

Musubi42 added 4 commits December 17, 2023 21:17
A commit allow to trigger a rebuild of Dashy, and publish changes automatically
The linter was already broken, line 93 too long and strict equality added
Upgrade minor version to 2
I have revoked the access token from my Github account
Copy link

vercel bot commented Dec 17, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
dashy ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 17, 2023 9:17pm

Copy link

netlify bot commented Dec 17, 2023

Deploy Preview for dashy-dev ready!

Name Link
🔨 Latest commit ac49329
🔍 Latest deploy log https://app.netlify.com/sites/dashy-dev/deploys/657f6541485fa4000709ad98
😎 Deploy Preview https://deploy-preview-1413--dashy-dev.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚫 Merge Conflicts [PR] Submitted code needs rebasing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants