This repository has been archived by the owner on Aug 10, 2024. It is now read-only.
- Update game url #179
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
name: 26F Studio CI | |
on: | |
push: | |
branches: [ main ] | |
tags: [ v* ] | |
jobs: | |
main: | |
runs-on: ubuntu-latest | |
concurrency: | |
group: main | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: 'npm' | |
- name: Install Dependencies and Build | |
run: npm i && npm run build | |
- name: Deploy to AliYun | |
if: startsWith(github.ref, 'refs/tags/v') == true | |
uses: wlixcc/[email protected] | |
with: | |
delete_remote_files: true | |
local_path: './dist/pwa/*' | |
remote_path: '${{ secrets.SFTP_REMOTE_PATH }}' | |
server: '${{ secrets.SFTP_SERVER }}' | |
sftpArgs: '-o ConnectTimeout=5' | |
ssh_private_key: ${{ secrets.SFTP_PRIVATE_KEY }} | |
username: '${{ secrets.SFTP_USERNAME }}' | |
- name: Download and modify 404.html for github pages | |
env: | |
DIST_PATH: ./dist/pwa | |
HTML_404_URL: https://raw.githubusercontent.com/rafgraph/spa-github-pages/gh-pages/404.html | |
shell: python3 {0} | |
run: | | |
import json | |
import os | |
os.system("wget ${{ env.HTML_404_URL }} -O ${{ env.DIST_PATH }}/404.html") | |
with open("${{ env.DIST_PATH }}/index.html", "r", encoding="utf-8") as index_html_file: | |
index_html = index_html_file.read() | |
index_html = index_html[index_html.find("<title>"):index_html.find("</script>",index_html.find("</script>")+1)+9] | |
with open("${{ env.DIST_PATH }}/404.html", "r+", encoding="utf-8") as notfound_html_file: | |
notfound_html = notfound_html_file.read() | |
insert_pos = notfound_html.find("<meta") | |
notfound_html = notfound_html[:insert_pos] + notfound_html[notfound_html.find("<script"):] | |
notfound_html = notfound_html[:insert_pos] + index_html + notfound_html[insert_pos:] | |
notfound_html_file.seek(0) | |
notfound_html_file.truncate() | |
notfound_html_file.write(notfound_html) | |
# - name: Deploy to GitHub Pages | |
# uses: crazy-max/ghaction-github-pages@v3 | |
# env: | |
# DIST_PATH: ./dist/pwa | |
# GH_PAT: ${{ secrets.FINE_PAT }} | |
# with: | |
# build_dir: ${{ env.DIST_PATH }} | |
# fqdn: dev.studio26f.org | |
# keep_history: false | |
# repo: 26F-Studio/26F-Studio.github.io | |
# target_branch: main | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
env: | |
DIST_PATH: ./dist/pwa | |
with: | |
name: 26F-Studio_PWA | |
path: ${{ env.DIST_PATH }} |