Build all template PDF and release it #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = 17 | |
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@v2 | |
# 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@v2 | |
with: | |
# název zip souboru se specifickým jménem předmětu | |
name: ${{ env.NAME }} | |
# 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@v2 | |
- name: Create tag | |
id: create_tag | |
run: | | |
tag=build-$(date +%Y%m%d-%H%M%S) | |
echo "::set-output name=tag::$tag" | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
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@v2 | |
- 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@v2 | |
with: | |
name: ${{ env.NAME }} | |
# přidání do releasu | |
- name: Upload artifact to Release | |
uses: actions/upload-release-asset@v1 | |
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: ${{ env.NAME }}.pdf | |
asset_content_type: application/pdf |