forked from wdw21/songbook
-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (69 loc) · 3.18 KB
/
generate_push.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: Generate Song Artifact on Push
run-name: Generating song
on:
pull_request:
paths:
- '**.xml'
permissions: read-all
jobs:
Generate-artifacts:
runs-on: ubuntu-latest
steps:
- run: echo "release_name=$(date +'%Y-%m-%dT%H_%M_%S')" >> $GITHUB_ENV
- run: echo "Generating a songbook PDF triggered by ${{ github.event_name }} release:${{ env.release_name }}"
- run: |
echo "DUMP: ${{ github }}"
- name: Check out repository code
uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip' # caching pip dependencies
- run: sudo apt-get install python3-lxml
- run: pip3 install -r ${{ github.workspace }}/requirements.txt
- run: pip install lxml
- name: Get changed files
id: changed-xml-files
uses: tj-actions/[email protected]
with:
fetch_depth: 500
files: |
songs/*.xml
- name: List all changed files
run: |
for file in "${{ steps.changed-xml-files.outputs.all_changed_files }}"; do
echo "$file was changed"
done
- if: steps.changed-xml-files.outputs.any_changed == 'true'
run: sudo apt-get install texlive texlive-latex-extra texlive-lang-polish
- name: Generate PDFs
if: steps.changed-xml-files.outputs.any_changed == 'true'
run: |
chmod 755 ./render_pdf.sh
cd ${{ github.workspace }} && ./render_pdf.sh single a4 "$(date +'%Y-%m-%d')" ${{ steps.changed-xml-files.outputs.all_changed_files }}
mv '${{ github.workspace }}/build/songs_tex/output.pdf' '${{ github.workspace }}/build/songs_tex/a4.pdf'
cd ${{ github.workspace }} && ./render_pdf.sh single a5 "$(date +'%Y-%m-%d')" ${{ steps.changed-xml-files.outputs.all_changed_files }}
mv '${{ github.workspace }}/build/songs_tex/output.pdf' '${{ github.workspace }}/build/songs_tex/a5.pdf'
- name: Save artifact
if: steps.changed-xml-files.outputs.any_changed == 'true'
uses: actions/upload-artifact@v3
with:
name: songbooks
path: ${{ github.workspace }}/build/songs_tex/*.pdf
- name: Upload artifacts
if: steps.changed-xml-files.outputs.any_changed == 'true'
run: |
for format in "a4" "a5"; do
FILENAME=$(echo "${{github.repository}}/${{github.sha}}_${format}.pdf" | sed 's|/|%2F|g' )
LINK="https://firebasestorage.googleapis.com/v0/b/wdw-21.appspot.com/o/${FILENAME}"
echo "link_${format}=${LINK}" >> $GITHUB_ENV
curl -v --data-binary "@${{ github.workspace }}/build/songs_tex/${format}.pdf" "${LINK}" -H 'Content-Type: application/pdf'
done
- name: Comment PR proxy
uses: mshick/add-pr-comment@v2
with:
message: |
New PDFs [A4](${{ env.link_a4 }}?alt=media), [A5](${{ env.link_a5 }}?alt=media) is ready, my lord (available for ~14 days).
Cieplutkie PDFy [A4](${{ env.link_a4 }}?alt=media), [A5](${{ env.link_a5 }}?alt=media) podano.
proxy-url: https://editor-github-pr-proxy-2tnk3uvmqq-ey.a.run.app
- run: echo "DONE"