Commit f19e030d authored by liziwl's avatar liziwl
Browse files

fix workflow

parent 931fdac6
Loading
Loading
Loading
Loading
+0 −21
Original line number Diff line number Diff line
@@ -32,15 +32,6 @@ jobs:
            sustechthesis.pdf
            public-test/*.pdf

      # - name: Deploy PDF to latest branch
      #   uses: peaceiris/actions-gh-pages@v3
      #   if: github.ref == 'refs/heads/master'
      #   with:
      #     github_token: ${{ secrets.GITHUB_TOKEN }}
      #     publish_dir: ./public-test
      #     publish_branch: latest
      #     force_orphan: true

  sync:
    runs-on: ubuntu-latest
    name: Sync to other git service
@@ -52,18 +43,6 @@ jobs:
    # needs: build_latex
    steps:

    # - name: Push to gitee
    #   run: |
    #     mkdir -p /tmp/tmp_push
    #     cd /tmp/tmp_push
    #     git clone --bare https://github.com/liziwl/sustech-master-thesis.git this_repo
    #     cd this_repo
    #     git push --force --mirror "https://${USER}:${PERSONAL_TOKEN}@${REPO_URL}"
    #   env:
    #     USER: ${{ secrets.GITEE_USER }}
    #     PERSONAL_TOKEN: ${{ secrets.GITEE_PERSONAL_TOKEN }}
    #     REPO_URL: "gitee.com/liziwl/sustech-master-thesis.git"

    - name: Push to sustech-git
      run: |
        tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX)
+43 −16
Original line number Diff line number Diff line
@@ -61,15 +61,35 @@ def rollback(filename, mode):
        shutil.copyfile(f'{filename}.lock', filename)


def backup(filename, mode):
    if mode:
        # before change, backup
        try:
            shutil.copyfile(filename, f'{filename}.undo.bak')
        except:
            pass
    else:
        # after change, restore
        try:
            shutil.copyfile(f'{filename}.undo.bak', filename)
            os.remove(f'{filename}.undo.bak')
        except:
            pass


if __name__ == "__main__":
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument("--recipe", type=int, required=True, help='recipe value')
    parser.add_argument('--undo', action='store_true')
    args = parser.parse_args()
    TOBACKUP = not args.undo

    if args.recipe == 1:
        # chinese
        filename = "sustechthesis-example.tex"
        backup(filename, TOBACKUP)
        if not args.undo:
            change_line(filename,
                        "documentclass.+{sustechthesis}",
                        "documentclass[degree=master,language=chinese,cjk-font=external]{sustechthesis}"
@@ -77,6 +97,8 @@ if __name__ == "__main__":
    elif args.recipe == 2:
        # english
        filename = "sustechthesis-example.tex"
        backup(filename, TOBACKUP)
        if not args.undo:
            change_line(filename,
                        "documentclass.+{sustechthesis}",
                        "documentclass[degree=master,language=english,cjk-font=external]{sustechthesis}"
@@ -84,9 +106,14 @@ if __name__ == "__main__":
    elif args.recipe == 3:
        # biber
        filename = "sustechthesis-example.tex"
        backup(filename, TOBACKUP)
        if not args.undo:
            comment_line(filename, "bibliography{ref/refs}", True)
            comment_line(filename, "printbibliography", False)

        filename = "sustech-setup.tex"
        backup(filename, TOBACKUP)
        if not args.undo:
            comment_line(filename, "{gbt7714}", True)
            comment_line(filename, "citestyle{super}", True)
            comment_line(filename, "citestyle{numbers}", True)
+3 −9
Original line number Diff line number Diff line
@@ -5,26 +5,20 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
RT_DIR="$( dirname "${SCRIPT_DIR}" )"
mkdir "$RT_DIR/public-test"

# 备份原文件
cp "$RT_DIR/sustechthesis-example.tex" "$RT_DIR/sustechthesis-example.tex.bak"

# 生成中文预览
cp "$RT_DIR/sustechthesis-example.tex.bak" "$RT_DIR/sustechthesis-example.tex"
python3 "$RT_DIR/test/test-files.py" --recipe 1
make
cp "$RT_DIR/sustechthesis-example.pdf" "$RT_DIR/public-test/sustechthesis-example-cn.pdf"
python3 "$RT_DIR/test/test-files.py" --recipe 1 --undo

# 生成英文预览
cp "$RT_DIR/sustechthesis-example.tex.bak" "$RT_DIR/sustechthesis-example.tex"
python3 "$RT_DIR/test/test-files.py" --recipe 2
make
cp "$RT_DIR/sustechthesis-example.pdf" "$RT_DIR/public-test/sustechthesis-example-en.pdf"
python3 "$RT_DIR/test/test-files.py" --recipe 2 --undo

# 生成biber预览
cp "$RT_DIR/sustechthesis-example.tex.bak" "$RT_DIR/sustechthesis-example.tex"
python3 "$RT_DIR/test/test-files.py" --recipe 3
make
cp "$RT_DIR/sustechthesis-example.pdf" "$RT_DIR/public-test/sustechthesis-example-biber.pdf"

# 恢复源文件
mv "$RT_DIR/sustechthesis-example.tex.bak" "$RT_DIR/sustechthesis-example.tex"
python3 "$RT_DIR/test/test-files.py" --recipe 3 --undo