每當提交時resume.tex,我都會嘗試從我的簡歷存盤庫檔案中構建簡歷 pdf 。
我收到以下錯誤。
Error: File '/home/runner/work/resume/resume/resume.tex' cannot be found from the directory '/github/workspace'.
我應該如何訪問該resume.tex檔案?如果我只是說root_file: resume.tex,錯誤是:
Error: File 'resume.tex' cannot be found from the directory '/github/workspace'.
該.github/workflows/build_resume.yml檔案看起來像這樣。該resume.tex檔案位于我的存盤庫的根目錄中。
# This is a basic workflow to help you get started with Actions
name: Build PDF on commit.
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
# workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Github Action for LaTeX
uses: xu-cheng/latex-action@v2
with:
# The root LaTeX file to be compiled
root_file: ${{ github.workspace }}/resume.tex
# Interpret the root_file input as bash glob pattern
# glob_root_file: # optional
# The working directory for this action
# working_directory: # optional
# The LaTeX engine to be invoked
# compiler: # optional, default is latexmk
# Extra arguments to be passed to the LaTeX engine
# args: # optional, default is -pdf -file-line-error -halt-on-error -interaction=nonstopmode
# [Deprecated] Install extra packages by tlmgr
# extra_packages: # optional
# Install extra packages by apk
# extra_system_packages: # optional
# Install extra .ttf/.otf fonts.
# extra_fonts: ./fonts/*.ttf
# Arbitrary bash codes to be executed before compiling LaTeX documents
pre_compile: tlmgr update --self && tlmgr update --all
# Arbitrary bash codes to be executed after compiling LaTeX documents
post_compile: latexmk -c
# Instruct latexmk to enable --shell-escape
# latexmk_shell_escape: # optional
# Instruct latexmk to use LuaLaTeX
# latexmk_use_lualatex: # optional
# Instruct latexmk to use XeLaTeX
latexmk_use_xelatex: true
uj5u.com熱心網友回復:
當您想從當前存盤庫執行檔案時,您需要首先使用操作/簽出(在作業步驟的開頭)。
這將允許您在作業流程中訪問存盤庫$github_workspace(Github 環境變數之一)。
注意:您在使用 之后運行的所有命令都將action/checkout在存盤庫根目錄中執行。
例如,考慮到您的resume.tex檔案位于存盤庫的根目錄,您將使用如下內容:
name: Example
on:
push:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/[email protected]
- name: show resume.tex file content
run: cat resume.tex
這是來自個人存盤庫的另一個作業流示例,如果您想在作業流中執行位于存盤庫中的特定腳本,則遵循相同的邏輯。執行任何操作。
uj5u.com熱心網友回復:
如果有人希望這樣做,則需要執行以下步驟。
- 進入您的存盤庫。
- 使用xu-cheng/latex-action@v2編譯 Latex 檔案
- 檢查是否生成了 PDF。
- 將 PDF 推送到存盤庫。
執行此操作的組態檔將如下所示。
name: Github Actions CI to build pdf from tex source.
on: push
jobs:
build:
if: "!contains(github.event.head_commit.message, '[skip ci]')"
runs-on: ubuntu-latest
steps:
- name: Set up Git repository
uses: actions/checkout@v2
- name: Compile LaTeX document
uses: xu-cheng/latex-action@v2
with:
# The root LaTeX file to be compiled
root_file: resume_aditya_wagh.tex
# Interpret the root_file input as bash glob pattern
# glob_root_file: # optional
# The working directory for this action
# working_directory: # optional
# The LaTeX engine to be invoked
# compiler: # optional, default is latexmk
# Extra arguments to be passed to the LaTeX engine
args: -pdf -file-line-error -halt-on-error -interaction=nonstopmode
# Install extra packages by apk
# extra_system_packages: # optional
# Install extra .ttf/.otf fonts.
extra_fonts: ./fonts/*.ttf
# Arbitrary bash codes to be executed before compiling LaTeX documents
pre_compile: tlmgr update --self && tlmgr update --all
# Arbitrary bash codes to be executed after compiling LaTeX documents
post_compile: latexmk -c
# Instruct latexmk to enable --shell-escape
# latexmk_shell_escape: # optional
# Instruct latexmk to use LuaLaTeX
# latexmk_use_lualatex: # optional
# Instruct latexmk to use XeLaTeX
latexmk_use_xelatex: true
- name: Check pdf file
run: |
file resume_aditya_wagh.pdf | grep -q ' PDF '
- name: Upload file to repository
run: |
git config --global user.name "adityamwagh"
git config --global user.email "[email protected]"
git add resume_aditya_wagh.pdf
git commit -m "commit message"
git push
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/405349.html
標籤:
上一篇:使用帶有動態值的LoDashorderBy進行升序或降序排序
下一篇:XUnit2.4按順序運行測驗
