Converting travis page builder to GitHub Actions.

Signed-off-by: Tim 'mithro' Ansell <tansell@google.com>
diff --git a/.travis/fix-git.sh b/.github/scripts/fix-git.sh
similarity index 100%
rename from .travis/fix-git.sh
rename to .github/scripts/fix-git.sh
diff --git a/.travis/generate-html.sh b/.github/scripts/generate-html.sh
similarity index 88%
rename from .travis/generate-html.sh
rename to .github/scripts/generate-html.sh
index 5723720..4aa9859 100755
--- a/.travis/generate-html.sh
+++ b/.github/scripts/generate-html.sh
@@ -43,7 +43,16 @@
 # Output some information about the version of Project X-ray we are using.
 (
 	cd $TMPDIR/prjxray
+	# Add upstream if it doesn't exist
+	if git remote -v | grep -q SymbiFlow/prjxray; then
+		echo "Upstream repo already exists."
+	else
+		git remote add upstream https://github.com/SymbiFlow/prjxray.git
+		git fetch upstream
+	fi
+	# Make sure we have tags
 	git fetch --tags
+	# Reset to the right revision
 	git reset --hard $PRJXRAY_INFO_REVISION
 	echo
 	echo "Project X-Ray Revision $(git describe --long --tags --always)"
@@ -60,9 +69,11 @@
 )
 
 # Generate the HTML for each device we have a settings file for.
-for SETTINGS in $TMPDIR/prjxray/settings/*.sh; do
+for SETTINGS in $(ls $TMPDIR/prjxray/settings/*.sh | grep '7.sh$'); do
 	DEVICE="$(basename $SETTINGS .sh)"
 
+	export PYTHONPATH=$PYTHONPATH:$TMPDIR/prjxray
+
 	echo
 	echo "Generating for $DEVICE"
 	echo "--------------------------------------------"
@@ -95,7 +106,7 @@
 
 done
 
-cp COPYING html/COPYING
+cp LICENSE html/LICENSE
 
 # Generate the index page from the Info.md file
 python3 -m markdown \
diff --git a/.travis/push-html.sh b/.github/scripts/push-html.sh
similarity index 83%
rename from .travis/push-html.sh
rename to .github/scripts/push-html.sh
index 49e5190..ea1849b 100755
--- a/.travis/push-html.sh
+++ b/.github/scripts/push-html.sh
@@ -7,6 +7,9 @@
 	exit 1
 fi
 
+export GIT_COMMITTER_NAME="SymbiFlow Travis Bot"
+export GIT_COMMITTER_EMAIL="nobody@nowhere.com"
+
 export GIT_AUTHOR_NAME="$(git log -1 --pretty=%an)"
 export GIT_AUTHOR_EMAIL="$(git log -1 --pretty=%ae)"
 
@@ -54,12 +57,12 @@
 		git status
 		echo "--------------------------------------------"
 
-		if [ ! -z "$TRAVIS" ]; then
+		if [ ! -z "$GITHUB_WORKFLOW" ]; then
 			git commit -a \
-				-m "Travis build #$TRAVIS_BUILD_NUMBER of $CURRENT_REVISION" \
+				-m "GitHub Actions build #$GITHUB_RUN_NUMBER of $CURRENT_REVISION" \
 				-m "" \
-				-m "From https://github.com/$TRAVIS_REPO_SLUG/tree/$TRAVIS_COMMIT" \
-				-m "$TRAVIS_COMIT_MESSAGE"
+				-m "From https://github.com/$GITHUB_REPOSITORY/tree/$GITHUB_SHA" \
+				-m "$CURRENT_MESSAGE"
 		else
 			git commit -a \
 				-m "Manual build of $CURRENT_REVISION" \
diff --git a/.travis/requirements.txt b/.github/scripts/requirements.txt
similarity index 71%
rename from .travis/requirements.txt
rename to .github/scripts/requirements.txt
index 0c8edb2..6e02bf8 100644
--- a/.travis/requirements.txt
+++ b/.github/scripts/requirements.txt
@@ -1,2 +1,3 @@
 markdown
 pygments
+pyyaml
diff --git a/.travis/save-key.sh b/.github/scripts/save-key.sh
similarity index 70%
rename from .travis/save-key.sh
rename to .github/scripts/save-key.sh
index 705e42d..b581603 100755
--- a/.travis/save-key.sh
+++ b/.github/scripts/save-key.sh
@@ -2,16 +2,12 @@
 set -e
 set +x
 
-if [ ! -z "$TRAVIS_BRANCH" -a "$TRAVIS_BRANCH" != "master" ]; then
-	echo "On $TRAVIS_BRANCH, not saving key."
-	exit 0
-fi
-
 if [ ! -z "$GH_KEY" ]; then
+	mkdir -p ~/.ssh
 	ssh-agent > ~/.ssh/agent.sh
 	. ~/.ssh/agent.sh
 	mkdir -p ~/.ssh/
-	echo "$GH_KEY" | base64 -d > ~/.ssh/id_git
+	echo "$GH_KEY" > ~/.ssh/id_git
 	chmod 0400 ~/.ssh/id_git
 	ssh-keygen -y -f ~/.ssh/id_git > ~/.ssh/id_git.pub
 	ssh-add ~/.ssh/id_git
diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml
new file mode 100644
index 0000000..fa8e6ee
--- /dev/null
+++ b/.github/workflows/pages.yml
@@ -0,0 +1,42 @@
+name: Build GitHub Pages
+
+on:
+  push:
+    branches:
+      - master
+  workflow_dispatch:
+
+#env:
+#  global:
+#   - GIT_COMMITTER_NAME="SymbiYosys Travis Bot"
+#   - GIT_COMMITTER_EMAIL="nobody@nowhere.com"
+
+jobs:
+
+  Build-GitHub-Pages:
+    runs-on: ubuntu-18.04
+    steps:
+
+    - uses: actions/checkout@v2
+      with:
+        fetch-depth: 0
+
+    - name: Save SSH key
+      run: ./.github/scripts/save-key.sh
+      env:
+        GH_KEY: ${{ secrets.GH_KEY }}
+
+    - name: Set up Python
+      uses: actions/setup-python@v2
+      with:
+        python-version: '3.x'
+        cache: 'pip'
+
+    - name: Install Python Dependencies
+      run: pip install -r ./.github/scripts/requirements.txt
+
+    - name: Generate HTML pages
+      run: ./.github/scripts/generate-html.sh
+
+    - name: Push to gh-pages branch
+      run: if [ -e ~/.ssh/agent.sh ]; then source ~/.ssh/agent.sh; ./.github/scripts/push-html.sh; fi
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index e71ab8f..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,21 +0,0 @@
-language: python
-python:
-  - "3.6"
-
-env:
-  global:
-   - GIT_COMMITTER_NAME="SymbiYosys Travis Bot"
-   - GIT_COMMITTER_EMAIL="nobody@nowhere.com"
-
-before_install:
-  - ./.travis/save-key.sh
-  - ./.travis/fix-git.sh
-
-install:
-  - pip install -r ./.travis/requirements.txt
-
-script:
-  - ./.travis/generate-html.sh
-
-after_success:
-  - if [ -e ~/.ssh/agent.sh ]; then source ~/.ssh/agent.sh; ./.travis/push-html.sh; fi