Skip to content

GitHub actions improvements #786

GitHub actions improvements

GitHub actions improvements #786

Workflow file for this run

# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright 2023 spdx contributors
name: run spec-parser
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Set up Python
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: "3.12"
- name: get spec-parser
run: |
git clone --depth=1 --single-branch --branch=main https://github.com/spdx/spec-parser/
cd spec-parser
python3 -m pip install -r requirements.txt
python main.py -h
- name: run spec-parser
run: |
cd spec-parser
mkdir -p ${{ runner.temp }}/spec-parser.out
python main.py \
--gen-md \
--gen-refs \
--gen-rdf \
--out-dir ${{ runner.temp }}/spec-parser.out \
../model
- name: validate that context is valid
run: |
python3 -m pip install rdflib
python3 ./.github/workflows/test_context.py ${{ runner.temp }}/spec-parser.out/context.json
- uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
with:
name: spec-parser-artifacts
path: |
${{ runner.temp }}/spec-parser.out/model.ttl
${{ runner.temp }}/spec-parser.out/model.jsonld
${{ runner.temp }}/spec-parser.out/context.json
- name: get Ontospy
run: |
git clone --depth=1 --single-branch --branch=master https://github.com/lambdamusic/Ontospy.git
cd Ontospy
python3 -m pip install -r requirements.txt
python3 -m pip install -e .
- name: generate docs with Ontospy
run : |
cd Ontospy
mkdir -p ${{ runner.temp }}/auto-generated
ontospy gendocs -o ${{ runner.temp }}/auto-generated --type 2 --title SPDX-3.0 ${{ runner.temp }}/spec-parser.out/model.ttl
mkdir -p ${{ runner.temp }}/auto-generated/one_pager
ontospy gendocs -o ${{ runner.temp }}/auto-generated/one_pager --type 1 --title SPDX-3.0 ${{ runner.temp }}/spec-parser.out/model.ttl
- uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
with:
name: auto-generated
path: ${{ runner.temp }}/auto-generated
- name: commit changes to branch
if: github.ref_name == 'main'
run: |
git fetch
git checkout gh-pages
cp ${{ runner.temp }}/spec-parser.out/model.ttl .
cp ${{ runner.temp }}/spec-parser.out/model.jsonld .
cp ${{ runner.temp }}/spec-parser.out/context.json .
rm -rf /auto-generated/
cp -r ${{ runner.temp }}/auto-generated/ .
if [ -n "$(git status -s -- "auto-generated/" "*.ttl" "*.jsonld" "*.json")" ]
then
git add model.ttl model.jsonld context.json auto-generated/
git -c user.name="github-actions[bot]" -c user.email="41898282+github-actions[bot]@users.noreply.github.com" commit -s -m "Automated Upload" --author "${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>"
git push origin
fi