-
Notifications
You must be signed in to change notification settings - Fork 0
148 lines (146 loc) · 4.67 KB
/
prod.yml
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: Public Release Workflow
on:
push:
branches:
- main
jobs:
publish:
name: Publish Resume
runs-on: ubuntu-latest
if: ${{ !contains(github.event.head_commit.message, '[bot]') }}
permissions:
contents: write
steps:
- name: Package Management
run: |
DEBIAN_FRONTEND=noninteractive sudo apt-get -y --no-install-recommends install \
sed
- uses: actions/checkout@v4
with:
token: ${{ secrets.TOKEN }}
- uses: baileyjm02/markdown-to-pdf@v1
name: Convert Resume to HTML
with:
build_pdf: false
build_html: true
table_of_contents: false
theme: styles/style.css
extend_default_theme: true
input_path: RESUME.md
output_dir: /
- uses: actions/upload-artifact@v4
name: Upload HTML Artifact
with:
name: html
path: RESUME.html
if-no-files-found: error
- name: Custom PDF Header
run: |
sed -i '1s|.*|<div style="float:right">Checkout Links and Updates at <a href="https://www.maxkapral.com">maxkapral.com</a></div>|' RESUME.md
- uses: baileyjm02/markdown-to-pdf@v1
name: Convert RESUME to PDF
with:
build_pdf: true
build_html: false
table_of_contents: false
theme: styles/style.css
extend_default_theme: true
input_path: RESUME.md
output_dir: /
- uses: actions/upload-artifact@v4
name: Upload PDF Artifact
with:
name: pdf
path: RESUME.pdf
if-no-files-found: error
- uses: actions/github-script@v7
name: Delete Previous Release
continue-on-error: true
with:
script: |
try {
const { data } = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: 'latest'
});
await github.rest.repos.deleteRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: data.id
});
} catch (e) {
console.log(e);
}
try {
await github.rest.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'tags/latest'
});
} catch (e) {
console.log(e);
}
- name: Rename Files
run: |
mv RESUME.html index.html
mv RESUME.pdf CSCI_mkapral_12-2023.pdf
- uses: actions/github-script@v7
name: Create New Release
with:
script: |
const tag = 'latest';
const commit = context.sha;
try {
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${tag}`,
sha: commit
});
} catch (e) {
console.log(e);
throw e;
}
try {
const release = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: tag,
name: tag,
body: 'Latest Public Release',
draft: true,
prerelease: false
});
const fs = require('fs');
const path = require('path');
const filename = 'CSCI_mkapral_12-2023.pdf'
const pdf = fs.readFileSync(path.basename(`./${filename}`));
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release.data.id,
name: filename,
data: pdf,
headers: {
'content-length': pdf.length,
'content-type': 'application/pdf'
}
});
await github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release.data.id,
draft: false
});
} catch (e) {
console.log(e);
throw e;
}
- name: Force Commit HTML
run: |
git config --local user.name "actions[bot]"
git config --local user.email "<>"
git add index.html && \
git commit -m "[bot] Auto-Commit Generated HTML Resume" && \
git push -f