-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove generated files; add GH Actions to auto-build; docs
- Loading branch information
Showing
9 changed files
with
227 additions
and
121,397 deletions.
There are no files selected for viewing
This file contains 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,54 @@ | ||
name: Build and Deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- trigger-build | ||
- main | ||
workflow_dispatch: # Allows manual trigger | ||
|
||
jobs: | ||
build_and_deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out the repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up SSH for Git (deploy key) | ||
run: | | ||
mkdir -p ~/.ssh | ||
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519 | ||
chmod 600 ~/.ssh/id_ed25519 | ||
ssh-keyscan github.com >> ~/.ssh/known_hosts | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install Dependencies | ||
run: | | ||
python3 -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
- name: Fetch GitHub data | ||
run: | | ||
python3 gh-data.py | ||
- name: Merge data sources | ||
run: | | ||
python3 merge-data.py | ||
- name: Commit and Push Changes to `gh-pages` | ||
run: | | ||
git config --global user.name "github-actions[bot]" | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
git checkout -b gh-pages | ||
git add -f gh-data.json | ||
git add -f gh-data-summary.json | ||
git add -f merged-data.json | ||
git add . | ||
git commit -m "Update GitHub Pages with latest data" | ||
git remote set-url origin [email protected]:${{ github.repository }}.git | ||
git push origin gh-pages --force |
This file contains 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,12 @@ | ||
name: Label Change Action | ||
|
||
on: | ||
issues: | ||
types: [labeled, unlabeled] | ||
|
||
jobs: | ||
noop: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: No operation | ||
run: echo "Label changed. Detected by the scheduler." |
This file contains 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,77 @@ | ||
name: Schedule Label Change Action | ||
|
||
on: | ||
#schedule: | ||
# - cron: '*/60 * * * *' # Runs every 60 minutes | ||
workflow_dispatch: # Allows manual trigger | ||
|
||
jobs: | ||
check_and_run: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out the repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up SSH for Git (deploy key) | ||
run: | | ||
mkdir -p ~/.ssh | ||
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519 | ||
chmod 600 ~/.ssh/id_ed25519 | ||
ssh-keyscan github.com >> ~/.ssh/known_hosts | ||
- name: Get the last few workflow runs | ||
id: last-runs | ||
run: | | ||
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
-H "Accept: application/vnd.github+json" \ | ||
https://api.github.com/repos/${{ github.repository }}/actions/runs?branch=${{ github.ref_name }} \ | ||
| jq -c '.workflow_runs[] | {name: .name, conclusion: .conclusion}' > last_runs_info.txt | ||
- name: Print the contents of last_runs_info.txt | ||
run: | | ||
echo "Contents of last_runs_info.txt:" | ||
cat last_runs_info.txt | ||
- name: Ensure valid JSON output | ||
run: | | ||
if [ ! -s last_runs_info.txt ]; then | ||
echo "No workflow runs found or empty response. Exiting." | ||
exit 1 | ||
fi | ||
- name: Iterate over the recent workflows | ||
id: check-last-run | ||
run: | | ||
should_run=false | ||
while IFS= read -r line; do | ||
name=$(echo "$line" | jq -r '.name') | ||
conclusion=$(echo "$line" | jq -r '.conclusion') | ||
echo "Checking workflow: $name with conclusion: $conclusion" | ||
if [ "$name" == "Schedule Label Change Action" ] && [ "$conclusion" == "success" ]; then | ||
should_run=false | ||
break | ||
elif [ "$name" == "Label Change Action" ]; then | ||
should_run=true | ||
break | ||
fi | ||
done < last_runs_info.txt | ||
if [ "$should_run" == "true" ]; then | ||
echo "should_run=true" >> $GITHUB_ENV | ||
else | ||
echo "should_run=false" >> $GITHUB_ENV | ||
fi | ||
- name: Push changes to `trigger-build` branch | ||
if: env.should_run == 'true' | ||
run: | | ||
git config --global user.name "github-actions[bot]" | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
git checkout -b trigger-build | ||
git add . | ||
git commit --allow-empty -m "Trigger build and deploy workflow" | ||
git remote set-url origin [email protected]:${{ github.repository }}.git | ||
git push origin trigger-build --force |
This file contains 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,45 @@ | ||
# Building locally | ||
|
||
The data for the dashboard website is sourced from: | ||
|
||
- The `activities.yml` file | ||
- The GitHub issues in mozilla/standards-positions (text in OP, labels) | ||
|
||
To fetch the GitHub information: | ||
|
||
``` | ||
python3 gh-data.py | ||
``` | ||
|
||
This will create or overwrite `gh-data.json` and `gh-data-summary.json`. | ||
|
||
Then, to combine that data with the information in `activities.yml`: | ||
|
||
``` | ||
python3 merge-data.py | ||
``` | ||
|
||
This will create `merged-data.json` which is used by `index.html`. | ||
|
||
To view the dashboard page locally, you need to start a local web server: | ||
|
||
``` | ||
python3 -m http.server 8000 | ||
``` | ||
|
||
Then load http://localhost:8000/ in a web browser. | ||
|
||
## Publishing | ||
|
||
The generated JSON files are not added in the `main` branch. | ||
However, the GitHub Actions workflow setup will build and push the generated files to the `gh-pages` branch, | ||
to make it possible to review the history of the GitHub issue data. | ||
That branch is then published using GitHub Pages. | ||
|
||
The above happens on pushes to the `main` branch as well as when any labels are changed. | ||
The latter runs the `labels-change.yml` workflow directly and then the `schedule-labels-change.yml` checks the history of workflow jobs to determine if labels have changed, | ||
and if so pushes an empty commit to the `trigger-build` branch, | ||
which causes the `build-and-deploy.yml` workflow to run. | ||
|
||
The GitHub Actions need a deploy key (Settings, Deploy keys), | ||
stored as an environment secret named SSH_PRIVATE_KEY (Settings, Secrets and variables, Actions). |
This file contains 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
Oops, something went wrong.