Skip to content

Commit

Permalink
Aktualizace šablony obsahující CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
jedla97 committed May 7, 2022
1 parent 8e2f048 commit 61aaf16
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 2 deletions.
105 changes: 105 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
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{\subject}" 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
23 changes: 23 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Test if template is possible to be built

on:
pull_request:
types: [opened, reopened, edited, synchronize]
branches:
- main

jobs:
# build šablony
build:
runs-on: ubuntu-latest

steps:
- name: Set up Git repository
uses: actions/checkout@v2

# kompilace
- name: Build šablony
uses: xu-cheng/latex-action@v2
with:
latexmk_shell_escape: true
root_file: main.tex
Binary file added images/github-commit-hash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion main.tex
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
% Nepovinný argument: Cílová skupina dokumentu
\newcommand{\docgroup}{Informační bezpečnost, FEKT VUT}
% Nepovinný argument: URL repozitáře nebo jiný odkaz na dokument
\newcommand{\docurl}{https://github.com/VUT-FEKT-IBE/FEKT.tex}
\newcommand{\docurl}{https://github.com/VUT-FEKT-IBE/MPC-KRY}

% Přepsáním argumentu na 'false' vypnete balíček 'minted' pro sázení kódu.
% Pro jeho použití lokálně musíte mít v systému dostupný Python 3, python
Expand Down
2 changes: 1 addition & 1 deletion shared.tex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
% FEKT.tex
% https://github.com/VUT-FEKT-IBE/FEKT.tex
% Git hash repozitáře v době kopírování:
% Git hash repozitáře v době kopírování: b77dcfcacd30920c2327b0b7539e03d986dd986c

\documentclass[
% Velikost základního písma je 12 bodů
Expand Down

0 comments on commit 61aaf16

Please sign in to comment.