From 7526192154a1c3d4a885780ee00f6b2792928b8b Mon Sep 17 00:00:00 2001 From: John Ajera <37360952+jajera@users.noreply.github.com> Date: Tue, 31 Dec 2024 07:05:26 +0000 Subject: [PATCH] feat: set initial configuration defines initial configuration --- .github/workflows/commitmsg-conform.yml | 11 ++++ .github/workflows/markdown-lint.yml | 11 ++++ .github/workflows/update-metrics.yml | 67 +++++++++++++++++++++++ README.md | 2 +- data/metrics.json | 2 + index.html | 43 +++++++++++++++ scripts.js | 42 +++++++++++++++ style.css | 72 +++++++++++++++++++++++++ 8 files changed, 249 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/commitmsg-conform.yml create mode 100644 .github/workflows/markdown-lint.yml create mode 100644 .github/workflows/update-metrics.yml create mode 100644 data/metrics.json create mode 100644 index.html create mode 100644 scripts.js create mode 100644 style.css diff --git a/.github/workflows/commitmsg-conform.yml b/.github/workflows/commitmsg-conform.yml new file mode 100644 index 0000000..e7b4d63 --- /dev/null +++ b/.github/workflows/commitmsg-conform.yml @@ -0,0 +1,11 @@ +name: commit-message-conformance +on: + pull_request: {} +permissions: + statuses: write + checks: write + contents: read + pull-requests: read +jobs: + commitmsg-conform: + uses: actionsforge/actions/.github/workflows/commitmsg-conform.yml@main diff --git a/.github/workflows/markdown-lint.yml b/.github/workflows/markdown-lint.yml new file mode 100644 index 0000000..d9a2d67 --- /dev/null +++ b/.github/workflows/markdown-lint.yml @@ -0,0 +1,11 @@ +name: markdown-lint +on: + pull_request: {} +permissions: + statuses: write + checks: write + contents: read + pull-requests: read +jobs: + markdown-lint: + uses: actionsforge/actions/.github/workflows/markdown-lint.yml@main diff --git a/.github/workflows/update-metrics.yml b/.github/workflows/update-metrics.yml new file mode 100644 index 0000000..417bdbb --- /dev/null +++ b/.github/workflows/update-metrics.yml @@ -0,0 +1,67 @@ +name: update-gh-pages-metrics + +on: + schedule: + - cron: '0 0 * * 1' # Weekly schedule + workflow_dispatch: # Manual trigger + +permissions: + contents: write + statuses: write + +jobs: + update-metrics: + runs-on: ubuntu-latest + + steps: + # Step 1: Checkout the repository + - name: Checkout repository + uses: actions/checkout@v4 + + # Step 2: Install jq for JSON processing + - name: Install jq + run: | + sudo apt-get update + sudo apt-get install -y jq + + # Step 3: Fetch and generate metrics.json + - name: Generate metrics.json + env: + API_URL: "https://api.github.com/orgs/${{ github.repository_owner }}/repos" + METRICS_FILE: "data/metrics.json" + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # Validate token availability + if [[ -z "$GITHUB_TOKEN" ]]; then + echo "Error: GITHUB_TOKEN is not available." + exit 1 + fi + + # Prepare directories + rm -rf data && mkdir -p data + + # Fetch repository data + status_code=$(curl -s -o response.json -w "%{http_code}" -H "Authorization: token $GITHUB_TOKEN" "$API_URL") + + # Check HTTP status code + if [ "$status_code" -ne 200 ]; then + echo "Failed to fetch repository data. HTTP Status: $status_code" + echo "Response:" + cat response.json + exit 1 + fi + + # Parse and sort repositories by stargazers_count (top 5) + repos=$(jq -r '.[] | {(.name): .stargazers_count}' response.json | jq -s add | jq -r 'to_entries | sort_by(-.value)[:5] | from_entries') + + # Generate metrics.json + echo "$repos" | jq -r '.' > "$METRICS_FILE" + + echo "metrics.json generated successfully." + + # Step 4: Commit and push changes + - name: Commit and push changes + uses: EndBug/add-and-commit@v9 + with: + message: "Update metrics.json with top repositories" + add: "data/metrics.json" diff --git a/README.md b/README.md index 01acd06..ae705f8 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# actionsforge.github.io \ No newline at end of file +# actionsforge.github.io diff --git a/data/metrics.json b/data/metrics.json new file mode 100644 index 0000000..2c63c08 --- /dev/null +++ b/data/metrics.json @@ -0,0 +1,2 @@ +{ +} diff --git a/index.html b/index.html new file mode 100644 index 0000000..1d20a9d --- /dev/null +++ b/index.html @@ -0,0 +1,43 @@ + + + + + + ActionsForge Dashboard + + + + +
+

ActionsForge Organization Dashboard

+

Visualizing top repositories by GitHub stars

+
+ +
+
+ +
+ +
+

Top Repositories Data

+ + + + + + + + + + +
RepositoryStars
+
+
+ + + + + + diff --git a/scripts.js b/scripts.js new file mode 100644 index 0000000..663643f --- /dev/null +++ b/scripts.js @@ -0,0 +1,42 @@ +// Fetch and display the top repositories +fetch('./data/metrics.json') + .then(response => response.json()) + .then(data => { + // Prepare data for Chart.js + const labels = Object.keys(data); + const starCounts = Object.values(data); + + // Populate the chart + const ctx = document.getElementById('repoContributions').getContext('2d'); + new Chart(ctx, { + type: 'bar', + data: { + labels: labels, + datasets: [{ + label: 'Stars', + data: starCounts, + backgroundColor: 'rgba(75, 192, 192, 0.2)', + borderColor: 'rgba(75, 192, 192, 1)', + borderWidth: 1 + }] + }, + options: { + scales: { + y: { + beginAtZero: true + } + } + } + }); + + // Populate the table + const tableBody = document.querySelector('#data-table tbody'); + labels.forEach((repo, index) => { + const row = document.createElement('tr'); + row.innerHTML = `${repo}${starCounts[index]}`; + tableBody.appendChild(row); + }); + }) + .catch(error => { + console.error('Error fetching or processing data:', error); + }); diff --git a/style.css b/style.css new file mode 100644 index 0000000..afffcfb --- /dev/null +++ b/style.css @@ -0,0 +1,72 @@ +/* General Styles */ +body { + font-family: Arial, sans-serif; + margin: 0; + padding: 0; + background-color: #181818; /* Deep dark gray */ + color: #d4d4d4; /* Soft light gray for text */ + text-align: center; +} + +header { + background-color: #1e1e1e; /* Slightly lighter dark gray */ + color: #d4d4d4; + padding: 20px; + border-bottom: 2px solid #5e5e5e; /* Subtle gray highlight */ +} + +main { + padding: 20px; +} + +h1, h2 { + margin: 10px 0; + color: #ffffff; /* Bright white for headings */ +} + +/* Chart Section */ +#chart-section { + margin: 20px auto; + max-width: 600px; +} + +/* Table Styles */ +#data-table { + margin: 20px auto; + border-collapse: collapse; + width: 80%; + background-color: #242424; /* Dark gray for table background */ + color: #d4d4d4; /* Light gray text */ + border-radius: 8px; + overflow: hidden; +} + +#data-table th, #data-table td { + border: 1px solid #333333; /* Subtle dark border */ + padding: 12px 16px; + text-align: left; +} + +#data-table th { + background-color: #333333; /* Slightly lighter dark gray for headers */ + color: #f0f0f0; /* Off-white text for headers */ + font-weight: bold; + text-transform: uppercase; +} + +#data-table tr:nth-child(even) { + background-color: #2a2a2a; /* Slightly lighter for alternating rows */ +} + +#data-table tr:hover { + background-color: #3a3a3a; /* Hover effect with medium gray */ + color: #ffffff; /* Bright white text on hover */ + cursor: pointer; +} + +/* Footer */ +footer { + margin-top: 20px; + font-size: 0.9em; + color: #666666; /* Muted gray for footer text */ +}