📑
職務経歴書もCI/CD化!GitHub ActionsでPDFを自動生成
はじめに
エンジニアとしてのキャリアを築く中で、職務経歴書は自分のスキルや経験を整理し、アピールするための重要なツールです。しかし、職務経歴書の管理や更新が面倒に感じたことはありませんか?
この記事では、Markdownを使って職務経歴書を作成し、GitHubでバージョン管理、さらにGitHub Actionsを活用してPDFへの自動変換を行う方法を紹介します。この方法により、職務経歴書の管理が効率化され、常に最新の状態を保つことができます。
なぜMarkdownとGitHubを使うのか?
-
シンプルで読みやすい: Markdownは軽量マークアップ言語で、直感的に文書を構造化できます。
-
バージョン管理が容易: GitHubを使うことで、職務経歴書の変更履歴を簡単に追跡・管理できます。
-
自動化による効率化: GitHub Actionsを利用することで、Markdownファイルを更新するたびにPDFが自動生成されます。
実践
ディレクトリ全体像
├── .github
│ └── workflows
├── .gitignore
├── docs
│ ├── README.md
│ └── README.pdf
├── package-lock.json
├── package.json
└── pdf-configs
├── config.js
└── style.css
必要パッケージの追加
npm install --save-dev md-to-pdf
package.json
に以下を追記
package.json
{
"scripts": {
// ... existing code ...
"build:pdf": "md-to-pdf docs/README.md --config-file ./pdf-configs/config.js --launch-options '{\"args\":[\"--no-sandbox\",\"--disable-setuid-sandbox\"]}'"
// ... existing code ...
}
}
pdf_configs
配下の config.js
とstyle.css
config.js
module.exports = {
stylesheet: "./pdf-configs/style.css",
body_class: "markdown-body",
marked_options: {
headerIds: false,
smartypants: true,
},
launch_options: {
args: ['--no-sandbox', '--disable-setuid-sandbox']
},
pdf_options: {
format: 'A4',
margin: {
top: '20mm',
right: '20mm',
bottom: '20mm',
left: '20mm'
},
printBackground: true,
"headerTemplate": "<style>\n section {\n margin: 0 auto;\n font-size: 9px;\n }\n</style>",
"footerTemplate": "<section>\n <div>\n <span class=\"pageNumber\"></span>\n / <span class=\"totalPages\"></span>\n </div>\n</section>"
},
stylesheet_encoding: "utf-8",
};
style.css
@import url(//fonts.googleapis.com/earlyaccess/notosansjapanese.css);
body {
font-size: 12px;
font-family: "Noto Sans Japanese", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}
h1:first-child {
margin-top: 0;
padding-top: 0;
text-align: center;
}
table {
font-size: 11px;
border-collapse: collapse;
}
td,
th {
border: 1px solid #ddd;
padding: 5px;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
tr:hover {
background-color: #ddd;
}
th {
text-align: left;
background-color: #ddd;
}
hr {
border-top: 1px solid #ddd;
margin: 30px 0;
}
GitHub Actions の準備
- PATを生成
- Expiration: No expiration
- Select scopes: repo
- Repository secrets に登録する
.github/workflows
配下に、generate.yaml
を作成
generate.yaml
name: Generate PDF
on:
push:
branches:
- main
paths:
- 'docs/README.md'
jobs:
generate-pdf:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GH_PAT }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm install
- name: Generate PDF
run: npm run build:pdf
env:
PDF_CONFIG_FILE: ./pdf-configs/config.js
- name: Commit and push
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git pull origin main
git add docs/README.pdf
git commit -m "docs: 職務経歴書のPDFを更新" || exit 0
git remote set-url origin https://x-access-token:${GH_PAT}@github.com/${{ github.repository }}
git push
env:
GH_PAT: ${{ secrets.GH_PAT }}
README.md に職務経歴を記述する
以下は、実際に使用している職務経歴書のMarkdownテンプレートです。自分の経歴に合わせてカスタマイズしてみてください。
README.md
# 職務経歴書
## 基本情報
| 項目名 | 内容 |
| -------- | ---------------------------------------------------- |
| 名前 | |
| 生年月 | |
| 居住地 | |
| 最終学歴 | |
## 職務要約
## スキルセット
### 言語・フレームワーク
### インフラ・クラウド
### データベース
### ツール・その他
## 職務経歴詳細
### 会社名
**フルスタックエンジニア(正社員)**
2024 年 12 月 ~ 現在
#### 業務内容
#### 主な実績
## 自己 PR
## 保有資格
| 資格名 | 取得日 |
| --------------------------------------------------- | ------------- |
| | |
## バリューを発揮しやすい業務
## バリューを発揮しやすい環境
mainへpush!!
最後に、mainへpushすれば、GitHub Actions が自動でdocs/README.pdf
を生成します
生成されたPDFの例
おわりに
職務経歴書を常に最新に保つためにもぜひ活用してみてください。
今回は、PDFへの自動変換のみを説明しましたが、lintなどを導入することで、職務経歴書の品質も保つようにすると、さらによくなると思います。
Discussion