Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test PR #34

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# exclude .gitignore and similar from the release zip file
.git* export-ignore
# exclude README and index.html from the release zip file
README.md export-ignore
index.html export-ignore
# exclude JSON Schema files from the release zip file
*.schema.json export-ignore
84 changes: 84 additions & 0 deletions .github/workflows/create-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Create PR for latest Activity List and Collections

on:
workflow_dispatch:
repository_dispatch:
types: [activity-list-update]

jobs:
generate:
runs-on: ubuntu-latest

steps:
- name: Check out this repository
uses: actions/checkout@v2
with:
path: activity-list

- name: Download Zip File of latest activity list and collections from activity-list-editor.
run: |
mkdir -p downloads
wget -O downloads/openactive_concepts.zip https://oa-activity-list-staging-87b008e57ad8.herokuapp.com/en/openactive_concepts.zip

- name: Extract Zip File
run: |
mkdir -p activity-list-editor
unzip downloads/openactive_concepts.zip -d activity-list-editor

- name: Install jq
run: |
sudo apt-get update
sudo apt-get install -y jq

- name: Compare current activity list with activity list from activity-list-editor
id: compare
uses: openactive/skos-compare-action@main
with:
new_json_file: './activity-list-editor/activity-list.jsonld'
old_json_file: './activity-list/activity-list.jsonld'

# For security reasons, we only copy valid JSON-LD files to the next step
- name: Validate and Copy JSON-LD files
run: |
FILES=$(find activity-list-editor -name '*.jsonld')
for file in $FILES; do
if jq empty "$file" 2>/dev/null; then
echo "Valid JSON-LD: $file"
cp "$file" activity-list/
else
echo "Invalid JSON-LD, skipping: $file"
fi
done

- name: Generate list of changed files in /collections/ directory
id: collections_changed
run: |
git diff --name-only origin/main...HEAD -- ./collections/ > ../changed_collections_files.txt
echo "::set-output name=changed_files::$(cat ../changed_collections_files.txt)"
working-directory: ./activity-list/

- name: Create Pull Request
if: ${{ steps.compare.outputs.hasChanges || steps.collections_changed.outputs.changed_files }}
id: cpr
uses: peter-evans/create-pull-request@v6
with:
path: ./activity-list/
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
commit-message: Update activity list and collections
committer: openactive-bot <[email protected]>
author: openactive-bot <[email protected]>
signoff: false
branch: ci/update-activity-list
delete-branch: true
title: 'Update activity list and collections'
body: |
${{ steps.compare.outputs.hasChanges && 'The following changes have been made to the OpenActive Activity List:\n' }}:${{ steps.compare.outputs.changeDescription }}
${{ steps.collections_changed.outputs.changed_files && '\nThe following changes have been made to the OpenActive Collections:\n' }}:${{ steps.collections_changed.outputs.changed_files }}
labels: |
automated pr
draft: false

- name: Check outputs
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
47 changes: 47 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Release

on:
push:
branches: [ master, develop ]

jobs:
publish:
runs-on: ubuntu-latest

steps:
- id: commit-date
name: Get latest commit date
uses: ithaque-renovation/latest-commit-date-action@v1

- name: Render PR body
id: fetch_pr
uses: actions/github-script@v7
with:
script: |
const { data: pulls } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'closed',
head: context.sha
});
const pr = pulls.find(pr => pr.merge_commit_sha === context.sha);
if (pr) {
return `${pr.body}\n\nAssociated PR: #${pr.number}`;
} else {
console.log('No associated PR found; skipping release creation.');
return null;
}

- name: Create Release
if: "!contains(toJSON(github.event.commits.*.message), '[no-release]') && steps.fetch_pr.outputs.result != null"
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.commit-date.outputs.latest-commit-date }}
release_name: Release v${{ steps.commit-date.outputs.latest-commit-date }}
body: ${{ steps.fetch_pr.outputs.result }}
draft: false
prerelease: false

50 changes: 50 additions & 0 deletions .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Validate activity-list.jsonld

on:
pull_request:
branches: [ master, develop ]
push:
branches: [ master, develop ]

jobs:
Validate:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Install Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: '20.x'
- name: Install dependencies
run: npm install @openactive/skos ajv
- name: Validate activity-list.jsonld
uses: actions/github-script@v7
with:
script: |
const Ajv = require('ajv');
const fs = require('fs');
const skos = require('@openactive/skos');

var schemafile = "./activity-list.schema.json";
var rawfile = "./activity_list.jsonld";

let schema = JSON.parse(fs.readFileSync(schemafile));
let data = JSON.parse(fs.readFileSync(rawfile));

var ajv = new Ajv({ allErrors: 'true', verbose: 'true' });

var validate = ajv.compile(schema);
var is_valid = validate(data);

// Try to load into SKOS.js (will throw on failure)
var scheme = new skos.ConceptScheme(data);

if(is_valid){
console.log("activity-list.jsonld passed validation");
} else {
const errorMessage = "activity-list.jsonld failed validation"
console.log(`${errorMessage}\n=======\n`);
console.log(validate.errors);
throw new Error(errorMessage);
}
29 changes: 0 additions & 29 deletions .github/workflows/validation_flow.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
node_modules
.DS_Store
24 changes: 1 addition & 23 deletions activity-list.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,6 @@
"type": "ConceptScheme",
"license": "https://creativecommons.org/licenses/by/4.0/",
"concept": [
{
"id": "https://openactive.io/activity-list#117e7f70-6c42-4b1f-a3bb-620b63ea2632",
"identifier": "117e7f70-6c42-4b1f-a3bb-620b63ea2632",
"type": "Concept",
"prefLabel": "11-a-side",
"broader": [
"https://openactive.io/activity-list#0a5f732d-e806-4e51-ad40-0a7de0239c8c"
],
"definition": "The game of football made up of teams of 11 players",
"notation": "11_a_side"
},
{
"id": "https://openactive.io/activity-list#a71d477f-7263-43d7-8d17-3d69bda8991b",
"identifier": "a71d477f-7263-43d7-8d17-3d69bda8991b",
"type": "Concept",
"prefLabel": "20-20-20",
"broader": [
"https://openactive.io/activity-list#261395e5-9e11-4348-8bef-e0fafef0e765"
],
"definition": "The 20/20/20 class is designed to give you the ultimate challenge and total body workout. Sweat through 20 minutes of cardio, 20 minutes of strength training, and 20 minutes of stretching and core work.",
"notation": "202020"
},
{
"id": "https://openactive.io/activity-list#64ba748e-d7f0-46bd-ac49-63820c5eb10e",
"identifier": "64ba748e-d7f0-46bd-ac49-63820c5eb10e",
Expand Down Expand Up @@ -9259,4 +9237,4 @@
"notation": "zumbini"
}
]
}
}
File renamed without changes.
52 changes: 0 additions & 52 deletions package-lock.json

This file was deleted.

23 changes: 0 additions & 23 deletions package.json

This file was deleted.

Loading
Loading