Skip to content

Commit e518ce1

Browse files
committed
init
0 parents  commit e518ce1

File tree

709 files changed

+3162704
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

709 files changed

+3162704
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
name: Deploy Static Site
2+
3+
on:
4+
push:
5+
branches: [main]
6+
tags: ['v*']
7+
delete:
8+
9+
jobs:
10+
deploy:
11+
if: github.event_name == 'push'
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Read deploy version from deploy.json
20+
id: version
21+
run: |
22+
DEPLOY_VERSION=$(jq -r '.deploy' deploy.json)
23+
echo "Deploying version: $DEPLOY_VERSION"
24+
echo "version=$DEPLOY_VERSION" >> $GITHUB_OUTPUT
25+
26+
- name: Copy selected version to deploy/
27+
run: |
28+
REPO="${GITHUB_REPOSITORY##*/}"
29+
mkdir -p deploy
30+
DEPLOY_VERSION="${{ steps.version.outputs.version }}"
31+
32+
if [ "$DEPLOY_VERSION" = "latest" ]; then
33+
echo "Deploying root (latest) version"
34+
rsync -av \
35+
--exclude=versions \
36+
--exclude=.github \
37+
--exclude=.git \
38+
--exclude=.gitignore \
39+
--exclude=README.md \
40+
--exclude=deploy.json \
41+
./ ./deploy/
42+
else
43+
VERSION_FOLDER="versions/${REPO}_${DEPLOY_VERSION}"
44+
if [ -d "$VERSION_FOLDER" ]; then
45+
echo "Deploying from $VERSION_FOLDER"
46+
rsync -av "$VERSION_FOLDER/" ./deploy/
47+
else
48+
echo "⚠️ Version folder $VERSION_FOLDER does not exist, falling back to latest"
49+
rsync -av \
50+
--exclude=versions \
51+
--exclude=.github \
52+
--exclude=.git \
53+
--exclude=.gitignore \
54+
--exclude=README.md \
55+
--exclude=deploy.json \
56+
./ ./deploy/
57+
fi
58+
fi
59+
60+
- name: Deploy to GitHub Pages
61+
uses: peaceiris/actions-gh-pages@v4
62+
with:
63+
github_token: ${{ secrets.GITHUB_TOKEN }}
64+
publish_branch: gh-pages
65+
publish_dir: ./deploy
66+
67+
add_tag:
68+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
69+
runs-on: ubuntu-latest
70+
steps:
71+
- name: Checkout code
72+
uses: actions/checkout@v4
73+
with:
74+
fetch-depth: 0
75+
- name: Copy to versions/ on tag push
76+
run: |
77+
REPO="${GITHUB_REPOSITORY##*/}"
78+
TAG_NAME="${GITHUB_REF##refs/tags/}"
79+
mkdir -p "versions/${REPO}_${TAG_NAME}"
80+
rsync -av \
81+
--exclude=versions \
82+
--exclude=.github \
83+
--exclude=.git \
84+
--exclude=.gitignore \
85+
--exclude=README.md \
86+
--exclude=deploy.json \
87+
./ "versions/${REPO}_${TAG_NAME}/"
88+
89+
90+
- name: Commit version folder
91+
run: |
92+
REPO="${GITHUB_REPOSITORY##*/}"
93+
TAG_NAME="${GITHUB_REF##refs/tags/}"
94+
git config user.name github-actions
95+
git config user.email [email protected]
96+
git add "versions/${REPO}_${TAG_NAME}"
97+
98+
if git diff --cached --quiet; then
99+
echo "Nothing to commit"
100+
else
101+
git commit -m "Add ${REPO} version ${TAG_NAME}"
102+
git push origin HEAD:main
103+
fi
104+
105+
cleanup:
106+
if: github.event_name == 'delete' && github.event.ref_type == 'tag' && startsWith(github.event.ref, 'v')
107+
runs-on: ubuntu-latest
108+
steps:
109+
- name: Delete event info
110+
run: |
111+
echo "Event: $GITHUB_EVENT_NAME"
112+
echo "Ref: $GITHUB_REF"
113+
echo "Event ref: ${{ github.event.ref }}"
114+
- name: Checkout code
115+
uses: actions/checkout@v4
116+
with:
117+
ref: main
118+
token: ${{ secrets.GITHUB_TOKEN }}
119+
- name: Delete version folder
120+
run: |
121+
REPO="${GITHUB_REPOSITORY##*/}"
122+
TAG_NAME="${{ github.event.ref }}"
123+
FOLDER="versions/${REPO}_${TAG_NAME}"
124+
if [ -d "$FOLDER" ]; then
125+
git config user.name github-actions
126+
git config user.email [email protected]
127+
git rm -r "$FOLDER"
128+
if git diff --cached --quiet; then
129+
echo "Nothing to commit"
130+
else
131+
git commit -m "Delete version folder for deleted tag ${TAG_NAME}"
132+
git push origin main
133+
fi
134+
else
135+
echo "Folder $FOLDER does not exist. Skipping."
136+
fi

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Ignore VSCode workspace settings
2+
.vscode/

.idea/jobList.iml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 95 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# TimeRadar Static Site – GitHub Actions Versioning & Deployment
2+
3+
This repository is a static HTML site with automated deployment to GitHub Pages and versioned builds managed via Git tags and GitHub Actions.
4+
5+
## Features
6+
7+
- Deploys the current site to the `gh-pages` branch automatically on every push to `main`
8+
- Supports selective deployment using `deploy.json` to control which version is published (e.g., `v2.0.0` or `latest`)
9+
- Automatically saves versioned builds under `versions/TimeRadar_<version>/` when a tag is pushed. (No need to manually copy files into the `versions/` folder)
10+
- Automatically deletes the corresponding `versions/` folder when a version tag is deleted
11+
12+
---
13+
14+
15+
## Customizing Deployment with `deploy.json`
16+
17+
You can control what version of the site is deployed by editing the `deploy.json` file in the root of the repository.
18+
19+
#### Example
20+
21+
To deploy the latest development files from the root (default behavior):
22+
23+
```json
24+
{
25+
"deploy": "latest"
26+
}
27+
```
28+
To deploy a specific tagged version, for example v2.0.0, update the file to:
29+
```json
30+
{
31+
"deploy": "v2.0.0"
32+
}
33+
```
34+
## GitHub Pages Deployment
35+
36+
The site is deployed automatically via GitHub Actions whenever:
37+
38+
- You push to the `main` branch
39+
- You create or delete a version tag
40+
- You update the `deploy.json` file to change which version is deployed
41+
42+
The deployment system reads the `deploy.json` file to determine which version of the site to publish.
43+
44+
- If `"deploy": "latest"` → the root files are deployed (latest dev state)
45+
- If `"deploy": "vX.X.X"` → the corresponding folder under `versions/TimeRadar_vX.X.X/` is deployed
46+
47+
If the specified version doesn't exist, the deployment gracefully falls back to `latest`.
48+
The deployed site is served from the `gh-pages` branch.
49+
50+
### URL of Deployed Site
51+
```bash
52+
https://idataVisualizationLab.github.io/TimeRadar/
53+
```
54+
55+
56+
## GitHub Actions Workflow
57+
58+
The deployment and versioning behavior is defined in:
59+
```bash
60+
.github/workflows/deploy.yml
61+
```
62+
This workflow:
63+
64+
- Creates version folders inside `versions/` on tag push
65+
- Deletes corresponding version folders on tag deletion
66+
- Selectively deploys either a specific version or the latest based on `deploy.json`
67+
- Pushes the selected version to the `gh-pages` branch for public access
68+
69+
70+
## Add a New Version (Tag)
71+
To create a new version (for example, `v2.0.0`), use the following commands:
72+
```bash
73+
# Ensure your changes are committed and pushed to main first
74+
git tag v2.0.0
75+
git push origin v2.0.0
76+
```
77+
> **🚨 Important:** Tags must include the `v` prefix (e.g., `v1.0.0`, `v2.0.0`) to work correctly with the automated workflow.
78+
79+
#### This will:
80+
81+
- Copy the current project files into versions/TimeRadar_v2.0.0/
82+
- Commit that folder into the main branch automatically via GitHub Actions
83+
- Redeploy the site to GitHub Pages (excluding the versions/ folder)
84+
- You do not need to manually copy files into the versions/ folder — the GitHub workflow handles it.
85+
86+
## Delete a Version
87+
To delete a previously created version:
88+
```bash
89+
git tag -d v2.0.0
90+
git push origin :refs/tags/v2.0.0
91+
```
92+
#### This will:
93+
- Trigger a GitHub Action that automatically deletes the folder versions/TimeRadar_v2.0.0 from the main branch
94+
95+
96+
97+

deploy.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"deploy": "latest"
3+
}
4+
5+
1.12 MB
Loading
1.33 MB
Loading

0 commit comments

Comments
 (0)