Skip to content

Commit

Permalink
Add CI/CD workflow to validate YAML files (#40)
Browse files Browse the repository at this point in the history
* Add CI/CD workflow to validate YAML files

Signed-off-by: Dave Thaler <[email protected]>

* Update YAML files to resolve issues found by yamllint

Signed-off-by: Dave Thaler <[email protected]>

* Use directories not files

Signed-off-by: Dave Thaler <[email protected]>

---------

Signed-off-by: Dave Thaler <[email protected]>
Co-authored-by: Dave Thaler <[email protected]>
  • Loading branch information
dthaler and dthaler2 authored Apr 25, 2024
1 parent 6a1cd0e commit a3a3a4c
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 39 deletions.
78 changes: 39 additions & 39 deletions .github/workflows/generate-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name: Build

on:

Check warning on line 10 in .github/workflows/generate-files.yml

View workflow job for this annotation

GitHub Actions / validate-yaml

10:1 [truthy] truthy value should be one of [false, true]

Check warning on line 10 in .github/workflows/generate-files.yml

View workflow job for this annotation

GitHub Actions / validate-yaml

10:1 [truthy] truthy value should be one of [false, true]
push:
branches: [ main ]
branches: [main]

permissions:
contents: read
Expand All @@ -22,41 +22,41 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Generate files
working-directory: ${{github.workspace}}
run: |
python registry_tools/syncstandard.py
python registry_tools/makeTSV.py
python registry_tools/makeJSON.py
- 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/main . || echo "::set-output name=status::changes"
shell: bash

- name: Create Pull Request
if: steps.diff.outputs.status == 'changes'
run: |
git checkout -b generated-files
git add .
git commit -m "Update generated files"
git push -f origin generated-files
if ! gh pr list | grep -q "generated-files"; then
gh pr create -B main -H generated-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 }}
- name: Check out repository
uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Generate files
working-directory: ${{github.workspace}}
run: |
python registry_tools/syncstandard.py
python registry_tools/makeTSV.py
python registry_tools/makeJSON.py
- 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/main . || echo "::set-output name=status::changes"
shell: bash

- name: Create Pull Request
if: steps.diff.outputs.status == 'changes'
run: |
git checkout -b generated-files
git add .
git commit -m "Update generated files"
git push -f origin generated-files
if ! gh pr list | grep -q "generated-files"; then
gh pr create -B main -H generated-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 }}
26 changes: 26 additions & 0 deletions .github/workflows/validate-yaml.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 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: Validate-YAML

Check warning on line 6 in .github/workflows/validate-yaml.yml

View workflow job for this annotation

GitHub Actions / validate-yaml

6:1 [document-start] missing document start "---"

on:

Check warning on line 8 in .github/workflows/validate-yaml.yml

View workflow job for this annotation

GitHub Actions / validate-yaml

8:1 [truthy] truthy value should be one of [false, true]
push:
branches: [main, next-minor, next-patch]
pull_request:
branches: [main, next-minor, next-patch]

permissions:
contents: read

jobs:
validate-yaml:
runs-on: ubuntu-latest

steps:
- name: Checkout GEDCOM.io
uses: actions/checkout@v4

- name: Validate YAML
run: yamllint . .github .github/workflows calendar/standard data-type/standard enumeration/standard enumeration-set/standard month/standard structure/extension structure/standard uri/exid-types
8 changes: 8 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Configuration file for yamllint. For documentation, see
# https://yamllint.readthedocs.io/en/stable/configuration.html

extends: default

Check warning on line 4 in .yamllint.yml

View workflow job for this annotation

GitHub Actions / validate-yaml

4:1 [document-start] missing document start "---"

rules:
line-length: disable
trailing-spaces: disable

0 comments on commit a3a3a4c

Please sign in to comment.