-
Notifications
You must be signed in to change notification settings - Fork 5
137 lines (120 loc) · 4.91 KB
/
update-files.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# This action will regenerate generated files on a weekly schedule.
#
# For documentation on the github environment, see
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners
#
# For documentation on the syntax of this file, see
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
name: Update
on:
# Allow this workflow to be manually triggered.
workflow_dispatch:
# Run this once a week on saturday at 9pm UTC.
schedule:
- cron: '0 21 * * 6'
permissions:
contents: read
jobs:
generate-files:
permissions:
contents: write # for Git to git push
pull-requests: write # for Git to create a pull request
runs-on: ubuntu-latest
env:
SPECDIR: ../specification/
EXTDIR: ../extracted-files/
strategy:
matrix:
include:
- BRANCH: 'main'
GEDCOM_BRANCH: 'release'
- BRANCH: 'next-minor'
GEDCOM_BRANCH: 'v7.1'
- BRANCH: 'next-patch'
GEDCOM_BRANCH: 'main'
steps:
- name: Checkout GEDCOM.io
uses: actions/checkout@v4
with:
path: GEDCOM.io
ref: ${{matrix.BRANCH}}
- name: Checkout GEDCOM
if: matrix.GEDCOM_BRANCH != 'release'
uses: actions/checkout@v4
with:
repository: FamilySearch/GEDCOM
path: GEDCOM
ref: ${{matrix.GEDCOM_BRANCH}}
- name: Get latest release tag
if: matrix.GEDCOM_BRANCH == 'release'
id: latesttag
run: |
LATEST_TAG=$(curl --silent "https://api.github.com/repos/FamilySearch/GEDCOM/releases/latest" | jq -r .tag_name)
echo "::set-output name=tag::${LATEST_TAG}"
- name: Checkout latest GEDCOM release
if: matrix.GEDCOM_BRANCH == 'release'
uses: actions/checkout@v4
with:
repository: FamilySearch/GEDCOM
path: GEDCOM
ref: ${{steps.latesttag.outputs.tag}}
- name: Generate GEDOM-tmp.md
working-directory: ${{github.workspace}}/GEDCOM/build
shell: sh
run: |
export MD_FILES=$(ls ${{ env.SPECDIR }}gedcom*.md | sort)
python3 hyperlink.py ${MD_FILES} GEDCOM-tmp.md
ls -l GEDCOM-tmp.md
- name: Generate GEDCOM-tmp.html
working-directory: ${{github.workspace}}/GEDCOM/build
shell: sh
run: |
export MODTIME=$(git log -1 --date="format:%_d %B %Y" --format="%ad" -- ${SPECDIR})
export PDARGS="--syntax-definition=gedcom.xml --syntax-definition=gedstruct.xml --syntax-definition=abnf.xml --from=markdown+smart --standalone --css=pandoc.css --template=template.html --toc --number-sections --self-contained --highlight-style=kate --wrap=none"
docker run --rm --volume "`pwd`:/data" pandoc/latex:2.9 GEDCOM-tmp.md -o GEDCOM-tmp.html ${PDARGS} --metadata=date:"${MODTIME}"
ls -l GEDCOM-tmp.html
- name: Generate gedcom.html
working-directory: ${{github.workspace}}/GEDCOM/build
run: |
python3 hyperlink-code.py GEDCOM-tmp.html ../specification/gedcom.html
ls -l ../specification/gedcom.html
- name: Install weasyprint
run: |
python3 -mpip install --user weasyprint==52.5
- name: Generate gedcom.pdf
working-directory: ${{github.workspace}}/GEDCOM/build
run: |
python3 -mweasyprint ../specification/gedcom.html ../specification/gedcom.pdf
ls -l ../specification/gedcom.pdf
- name: Prep GEDCOM.io
if: matrix.GEDCOM_BRANCH == 'release'
working-directory: ${{github.workspace}}/GEDCOM/build
run: |
ls ../../GEDCOM.io
python3 push_to_gedcomio.py ../../GEDCOM.io
- name: Set git config
env:
GH_TOKEN: ${{ github.token }}
run: |
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git config --global user.name "$(gh api /users/${GITHUB_ACTOR} | jq .name -r)"
git config -l
- name: Check for diffs
id: diff
working-directory: ${{github.workspace}}/GEDCOM.io
run: |
git diff --quiet origin/${{matrix.BRANCH}} . || echo "::set-output name=status::changes"
shell: bash
- name: Create Pull Request
if: steps.diff.outputs.status == 'changes'
working-directory: ${{github.workspace}}/GEDCOM.io
run: |
git checkout -b generate-${{matrix.BRANCH}}-files
git add .
git commit -m "Update generated files"
git push -f origin generate-${{matrix.BRANCH}}-files
if ! gh pr list | grep -q "generate-${{matrix.BRANCH}}-files"; then
gh pr create -B ${{matrix.BRANCH}} -H generate-${{matrix.BRANCH}}-files --title 'Update generated files' --body $'Update generated files\nThis PR is auto-generated by [gh pr create].' --label 'automated pr'
fi
env:
GH_TOKEN: ${{ github.token }}