File tree Expand file tree Collapse file tree 5 files changed +110
-149
lines changed Expand file tree Collapse file tree 5 files changed +110
-149
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # Exit immediately if a command exits with a non-zero status.
4
+ set -e
5
+
6
+ # This script deploys the custom 404.html page to the root of the gh-pages branch.
7
+ # It's designed to be called from the GitHub Actions workflow.
8
+ #
9
+ # It expects one argument:
10
+ # $1: The GitHub repository name (e.g., "a2aproject/A2A").
11
+ #
12
+ # The script assumes that the git user name and email are already configured.
13
+
14
+ # --- Validate Input ---
15
+ if [ -z " $1 " ]; then
16
+ echo " Error: Missing required argument. Please provide the repository name (e.g., owner/repo)."
17
+ exit 1
18
+ fi
19
+
20
+ REPO_NAME=$1
21
+
22
+ echo " Deploying custom 404 page for repository: $REPO_NAME "
23
+
24
+ # --- Deployment Logic ---
25
+ # Clone the gh-pages branch into a temporary directory
26
+ git clone --branch=gh-pages --single-branch --depth=1 " https://github.com/${REPO_NAME} " gh-pages-deploy
27
+
28
+ # Copy the 404 page from the main branch checkout into the gh-pages clone
29
+ cp docs/404.html gh-pages-deploy/404.html
30
+
31
+ # Navigate into the cloned directory
32
+ cd gh-pages-deploy
33
+
34
+ # Add the 404 page to the staging area
35
+ git add 404.html
36
+
37
+ # Commit and push only if the 404 page has actually changed
38
+ if git diff --staged --quiet; then
39
+ echo " 404.html is up-to-date. No new commit needed."
40
+ else
41
+ echo " Committing and pushing updated 404.html..."
42
+ git commit -m " docs: deploy custom 404.html for redirects"
43
+ git push
44
+ fi
45
+
46
+ echo " 404 page deployment complete."
Original file line number Diff line number Diff line change 6
6
- main
7
7
paths :
8
8
- " .github/workflows/docs.yml"
9
+ - " .github/scripts/deploy-404.sh"
9
10
- " requirements-docs.txt"
10
11
- " mkdocs.yml"
11
12
- " docs/**"
14
15
- main
15
16
paths :
16
17
- " .github/workflows/docs.yml"
18
+ - " .github/scripts/deploy-404.sh"
17
19
- " requirements-docs.txt"
18
20
- " mkdocs.yml"
19
21
- " docs/**"
34
36
- name : Checkout Code
35
37
uses : actions/checkout@v4
36
38
with :
39
+ token : ${{ secrets.GITHUB_TOKEN }}
37
40
fetch-depth : 0
38
41
39
42
- name : Configure Git Credentials
64
67
- name : Deploy development version from main branch
65
68
if : github.event_name == 'push' && github.ref == 'refs/heads/main'
66
69
run : |
67
- echo "Deploying docs from main to the 'dev' version..."
68
- mike deploy --push --update-aliases dev
70
+ mike deploy --push --update-aliases dev latest
71
+
72
+ echo "Setting 'latest' as the default version for the site..."
73
+ mike set-default --push latest
74
+
75
+ # Deploy 404 page
76
+ bash .github/scripts/deploy-404.sh ${{ github.repository }} ${{ secrets.GITHUB_TOKEN }}
69
77
70
78
- name : Deploy new release version and set as latest
71
79
if : github.event_name == 'release'
77
85
78
86
echo "Setting 'latest' as the default version for the site..."
79
87
mike set-default --push latest
88
+
89
+ # Call the reusable script to deploy the 404 page, passing the token
90
+ bash .github/scripts/deploy-404.sh ${{ github.repository }} ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html >
3
+
4
+ < head >
5
+ < meta charset ="utf-8 ">
6
+ < title > Redirecting...</ title >
7
+ < script >
8
+ ( function ( ) {
9
+ const basePath = '/A2A/' ;
10
+ const latestVersion = 'latest' ;
11
+
12
+ const path = window . location . pathname ;
13
+ const redirected = sessionStorage . getItem ( 'redirected' ) ;
14
+
15
+ if ( redirected ) {
16
+ sessionStorage . removeItem ( 'redirected' ) ;
17
+ console . warn ( 'Redirect loop detected. Stopping redirect.' ) ;
18
+ return ;
19
+ }
20
+
21
+ // Check if the path is an asset or already a versioned path
22
+ const isAsset = path . includes ( '/assets/' ) || path . includes ( '/stylesheets/' ) ;
23
+ const isVersioned = new RegExp ( `${ basePath } (v?(\d+\.\d+(\.\d+)?)|${ latestVersion } )/` ) . test ( path ) ;
24
+
25
+ if ( ! isVersioned && ! isAsset ) {
26
+ // Construct the new URL.
27
+ // Example: /A2A/specification.md -> /A2A/latest/specification.md
28
+ const newPath = path . replace ( basePath , basePath + latestVersion + '/' ) ;
29
+
30
+ // Store a marker in sessionStorage to prevent loops
31
+ sessionStorage . setItem ( 'redirected' , 'true' ) ;
32
+
33
+ // Perform the redirect
34
+ window . location . replace ( newPath + window . location . search + window . location . hash ) ;
35
+ } else {
36
+ window . location . replace ( "https://a2aproject.github.io/A2A/" ) ;
37
+ }
38
+ } ) ( ) ;
39
+ </ script >
40
+ </ head >
41
+
42
+ < body >
43
+ < h1 > Page Not Found</ h1 >
44
+ < p > We are attempting to redirect you to the latest version of this page.</ p >
45
+ < p > If you are not redirected automatically, please navigate to the < a href ="/A2A/ "> project homepage</ a > .</ p >
46
+ </ body >
47
+
48
+ </ html >
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ site_description: >-
6
6
site_dir : site
7
7
8
8
extra :
9
- a2a_version : !ENV [MIKE_VERSION, 'local- dev']
9
+ a2a_version : !ENV [MIKE_VERSION, 'dev']
10
10
11
11
# Navigation
12
12
nav :
@@ -140,8 +140,7 @@ plugins:
140
140
- redirects :
141
141
redirect_maps :
142
142
" spec-json.md " : https://raw.githubusercontent.com/a2aproject/A2A/refs/heads/main/specification/json/a2a.json
143
- " specification/overview.md " : " latest/specification.md"
144
- " robots.txt " : " v0.2.5/robots.txt"
143
+ " specification/overview.md " : " specification.md"
145
144
" specification/agent-card.md " : " specification.md#5-agent-discovery-the-agent-card"
146
145
" specification/agent-to-agent-communication.md " : " specification.md#6-protocol-data-objects"
147
146
" specification/sample-messages.md " : " specification.md#9-common-workflows-examples"
@@ -188,6 +187,7 @@ plugins:
188
187
- " .ruff_cache"
189
188
- " node_modules"
190
189
- " __pycache__"
190
+ - " .DS_Store"
191
191
extra :
192
192
show_value : true
193
193
show_qualifiers : false
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments