Skip to content

[bot] Auto-Commit Generated HTML Resume #42

[bot] Auto-Commit Generated HTML Resume

[bot] Auto-Commit Generated HTML Resume #42

Workflow file for this run

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