From 6109456529304856b110bdfd132cd32ef70b074d Mon Sep 17 00:00:00 2001 From: SweetoCodes Date: Wed, 30 Oct 2024 15:29:24 +0000 Subject: [PATCH] added github action for remote building --- .github/workflows/build.yml | 36 ++++++++++++++++++++++++++++++++++++ .gitignore | 18 ++++++++++++++++++ README.md | 10 +++++++--- 3 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .gitignore diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..3395d19 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,36 @@ +name: Generate PDF from Markdown + +on: + push: + paths: + - '**/*.md' # Trigger this workflow on Markdown file changes + workflow_dispatch: # Allows manual trigger of the action + +jobs: + generate-pdf: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '18' + + - name: Install mdpdf + run: npm install -g mdpdf + + - name: Generate PDF + run: mdpdf cv.md --style=styles.css --border-top=12mm --border-bottom=0mm --border-left=4mm --border-right=4mm + + - name: Commit and push PDF + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + git add cv.pdf + git commit -m 'Generate PDF from Markdown' + git push + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub token for authentication diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5960ee0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,18 @@ +# Ignore node_modules directory +node_modules/ + +# Ignore log files +*.log + +# Ignore build directories +dist/ +build/ + +# Ignore OS-specific files +.DS_Store + +# Ignore environment variable files +.env + +# Ignore IDE-specific files +.vscode/ \ No newline at end of file diff --git a/README.md b/README.md index 3037eef..825d9f8 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,16 @@ ## Installation +By default, changes to the markdown file in this repository trigger a github action that builds a pdf from the markdown source and commits the file. + +To enable the comitting of this file back to this repository click on Settings > Actions > General and (under workflow permissions) select "Read and write permissions" & "Allow GitHub Actions to create and approve pull requests". ```bash -# Run Locally -# Install mdpdf glboally +# or run locally: + +# Install mdpdf globally npm install -g mdpdf@3.0.1 # Build pdf from markdown locally -mdpdf cv.md --style=styles.css --border-top=12mm --border-bottom=1mm --border-left=4mm --border-right=4mm +mdpdf cv.md --style=styles.css --border-top=12mm --border-bottom=0mm --border-left=4mm --border-right=4mm ``` ### About