Skip to content

Merge main into v7.1 (#563) #91

Merge main into v7.1 (#563)

Merge main into v7.1 (#563) #91

# This action will create generated files, and is done whenever the main branch is updated.
#
# 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: Generate files
on:
push:
branches: [main, v7.1]
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/
steps:
- name: Check out GEDCOM
uses: actions/checkout@v4
- name: Get the branch name
id: extract_branch
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
- name: Install mdformat-gfm
run: pip install mdformat-gfm
- name: Generate files
working-directory: ${{github.workspace}}/build
shell: sh
run: |
export MD_FILES=$(ls ${{ env.SPECDIR }}gedcom*.md | sort)
python3 extract-grammars.py ${MD_FILES} ${{ env.EXTDIR }}
python3 uri-def.py ${MD_FILES} ${{ env.EXTDIR }}tags
ls -l ${{env.EXTDIR}}
- 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
run: |
git diff --quiet origin/${{steps.extract_branch.outputs.branch}} extracted-files || echo "::set-output name=status::changes"
shell: bash
- name: Create Pull Request
if: steps.diff.outputs.status == 'changes'
run: |
git checkout -b ${{steps.extract_branch.outputs.branch}}-generate-files
git add extracted-files
git commit -m "Update extracted files"
git push -f origin ${{steps.extract_branch.outputs.branch}}-generate-files
if ! gh pr list | grep -q "${{steps.extract_branch.outputs.branch}}-generate-files"; then
gh pr create -B ${{steps.extract_branch.outputs.branch}} -H ${{steps.extract_branch.outputs.branch}}-generate-files --title 'Update extracted-files in ${{steps.extract_branch.outputs.branch}}' --body $'Update extracted files\nThis PR is auto-generated by [gh pr create].' --label 'automated pr'
fi
env:
GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}