Skip to content

use prod action token in dev #80

use prod action token in dev

use prod action token in dev #80

Workflow file for this run

name: Development Approval Workflow
on:
push:
branches-ignore:
- main
pull_request:
branches:
- main
jobs:
convert:
name: Build HTML & PDF Resume Files
runs-on: ubuntu-latest
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
template: .dev/templates/dev.html
theme: .dev/styles/dev.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
template: .dev/templates/dev.html
theme: .dev/styles/dev.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: 'dev'
});
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/dev'
});
} catch (e) {
console.log(e);
}
- uses: actions/github-script@v7
name: Create New Release
with:
script: |
const tag = 'dev';
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 Development Release',
draft: true,
prerelease: true
});
const fs = require('fs');
const path = require('path');
const pdfFileName = 'RESUME.pdf';
const pdf = fs.readFileSync(path.basename(`./${pdfFileName}`));
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release.data.id,
name: pdfFileName,
data: pdf,
headers: {
'content-length': pdf.length,
'content-type': 'application/pdf'
}
});
const htmlFileName = 'RESUME.html';
const html = fs.readFileSync(path.basename(`./${htmlFileName}`));
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release.data.id,
name: htmlFileName,
data: html,
headers: {
'content-length': html.length,
'content-type': 'text/html'
}
});
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;
}