Introduction

I have actually included hyperlinks to my personal resume on multiple websites, all pointing to the resume on my homepage. However, updating that homepage resume has become quite troublesome due to the frequent need for modifications and copying, so I haven’t updated it in a long time. After nearly a year of working with CI/CD workflows, I’ve gained a solid grasp of GitHub Actions, which led me to develop this resume compilation and distribution workflow. I’m documenting the pitfalls I’ve encountered along the way.

Workflow

Actually, the entire workflow is quite simple.

  1. Compile the tex file in the repository into a pdf file.
  2. Place the compiled pdf file into the pdf directory of my personal homepage and push the changes.

(Sounds simple, but I encountered quite a few pitfalls, spending nearly 6 hours on it.)

The compilation part didn’t take long. Initially, I wanted to use latexmk-actions1, but after checking, it didn’t fully meet my needs, and since it was still under active development, I abandoned it. I eventually switched to xu-cheng/latex-action@v22. I have to say, the author’s Actions configuration is excellent; it basically fulfilled all my requirements, including handling multiple directories and files without issue.

The main pitfall I encountered was related to 鉴权.

Since I had previously handled cross-repository operations, I typically just used an action like hugo-deploy or gh-pages-deploy, configuring the secrets accordingly. Naturally, I assumed I could handle the push operation with a simple action this time as well. I looked at many Actions related to push; the best-written one was ad-m/github-push-action@master3, but I kept getting the error Error: Invalid exit code: 128. I checked several similar issues reported by the author, but they didn’t resolve it. Google yielded no results, so I had to look for other solutions. I examined a few other options, but they also failed to solve my problem.

Going back to basics, we only need authentication plus the push operation. I wondered if I could authenticate during a Pull or a Push. I tried using the https://[username]:${{ secrets.PUBLISH_KEY }}@github.com/[username]/[repo] format during a Push, but it didn’t work. It didn’t work during a Pull either (though later I thought this approach might actually be feasible: just clone the repo, remove the .git information, treat it as a new repository, then add remote url, add that link, perform the Push, and include the --force parameter. It should work, but I don’t know if anyone has tried it hhh).

Actually, the final solution was the simplest method: utilizing actions/checkout instead of cloning. The official checkout action provides the ssh-key parameter (note: this is not token, unless you are using Personal Access Token instead of Deploy Key below).

The final workflow is as follows. You can view the file version here4.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
name: LaTex Compile and Push

on:
  push:
    branches: [main]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Set up Git repository
        uses: actions/checkout@v2
        with:
          persist-credentials: false

      - name: Set up HomePage
        uses: actions/checkout@v2
        with:
          repository: yyyanbj/yyyanbj.github.io
          ref: master
          path: homepage
          ssh-key: ${{ secrets.PUBLISH_KEY }}

      - name: Compile CV
        uses: xu-cheng/latex-action@v2
        with:
          root_file: |
            cv_en/cv_en.tex
            cv_cn/cv_cn.tex            
          work_in_root_file_dir: true
          latexmk_use_xelatex: true

      - name: Setup repository
        run: |
          ls -l ${GITHUB_WORKSPACE}
          ls -l ${GITHUB_WORKSPACE}/cv_cn
          ls -l ${GITHUB_WORKSPACE}/cv_en
          git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
          git config --global user.name "github-actions[bot]"
          cp ${GITHUB_WORKSPACE}/cv_cn/cv_cn.pdf homepage/pdf/cv_cn.pdf
          cp ${GITHUB_WORKSPACE}/cv_en/cv_en.pdf homepage/pdf/cv_en.pdf
          cd homepage && git commit -am "Update CV"
          git status
          git push origin master          

Implementation

This resume directory has two versions: one in Chinese and one in English. All required font resource files have been uploaded, so you can clone it directly and use it locally. The template was mainly modified from this project5, with some optimizations for Chinese characters.

Additionally, if you have a personal homepage and lack a LaTeX environment but want to compile or distribute the resume in the cloud, you can simply fork this repository, modify the cv_en.tex and cv_cn.tex files, and configure the workflows. The following section primarily covers the execution for those with such requirements.

The following content includes the following declarations: 主仓库: The repository where the PDF needs to be uploaded, e.g., yyyanbj/yyyanbj.github.io 本仓库: The repository containing the resume tex file, e.g., yyyanbj/cv

  1. Create the Resume

Open [https://github.com/yyyanbj/cv],点击右上角 to fork, navigate to the forked repository under your username, and clone it.

  1. Modify & Compile the Resume

Modify the tex file according to your needs, as well as the tex file within the subfolder cv.

  1. Distribute

Generate Deploy Key, refer to GitHub Authentication6

You can follow these steps: 1. ssh-keygen -t rsa -b 4096 -C "your_email@example.com" 2. Add id_rsa.pub to Settings -> Deploy Keys in the main repository; the name can be arbitrary, but you must grant write permissions 3. Add id_rsa to Settings -> Secrets in this repository, and fill in the name as PUBLISH_KEY

Allow GitHub Actions to run, modify the content in .github/workflows/latex.yml as needed (such as repository name, branch name, etc.), then push the changes to the GitHub repository and wait for the build to run.

Conclusion

I hope this helps. If this article or repository infringes upon any of your rights, please contact bj.yan.pa@qq.com, and I will handle it as soon as possible.