Skip to content

Merge pull request #2 from BeziCZ/main #2

Merge pull request #2 from BeziCZ/main

Merge pull request #2 from BeziCZ/main #2

Workflow file for this run

name: Build all template PDF and release it
# Feel free to increment this counter in your attempts to do things
# the smart way instead of the easy way.
#
# total_hours_wasted = 19
on:
push:
branches:
- main
paths:
- "**/*.tex"
- "**/*.png"
- "**/*.jpg"
workflow_dispatch:
jobs:
# build šablony
build:
runs-on: ubuntu-latest
steps:
- name: Set up Git repository
uses: actions/checkout@v4
# kompilace
- name: Build ${{ matrix.dir }}
uses: xu-cheng/latex-action@v2
with:
latexmk_shell_escape: true
working_directory: ${{ matrix.dir }}
root_file: main.tex
- name: Set env
run: echo "NAME=$(grep -F "\newcommand{\name}" main.tex | cut -d'{' -f 3 | cut -d'}' -f 1)" >> $GITHUB_ENV
# nahrání pro pozdější stažení
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
# název zip souboru se specifickým jménem předmětu
name: "FEKT.tex"
# co se má uložit do zip souboru
path: main.pdf
# vytvoření prázdného releasu
release:
runs-on: ubuntu-latest
needs: [ build ]
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Set up Git repository
uses: actions/checkout@v4
- name: Create tag
id: create_tag
run: |
tag=build-$(date +%Y%m%d-%H%M%S)
echo "TAG=$tag" >> "$GITHUB_OUTPUT"
- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.create_tag.outputs.TAG }}
release_name: ${{ steps.create_tag.outputs.TAG }}
draft: false
prerelease: false
# přidání jednotlivých pdf předmětů do releasu
addBuilt:
runs-on: ubuntu-latest
# potřeba listOfDirectories pro vytvoření jobs matrix
needs: [ build, release ]
steps:
- uses: actions/checkout@v4
- name: Set env
run: echo "NAME=$(grep -F "\newcommand{\subject}" main.tex | cut -d'{' -f 3 | cut -d'}' -f 1)" >> $GITHUB_ENV
# stažení dříve nahráneho zip souboru v subjects jobu
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: "FEKT.tex"
- name: Display structure of downloaded files
run: ls -R
# přidání do releasu
- name: Upload artifact to Release
uses: actions/upload-release-asset@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
# cesta k souboru
asset_path: ./main.pdf
# název v releasu
asset_name: MPC-KRY.pdf
asset_content_type: application/pdf