Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
Add publish action (#9)
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Hinek <[email protected]>
  • Loading branch information
frankhinek authored Jul 12, 2024
1 parent 639943b commit 40a35d9
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 2 deletions.
99 changes: 99 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Publish Schemas

on:
# Trigger the workflow every time you push to the `main` branch
push:
branches: [ main ]

# Every run step in this workflow will use Bash as the default shell
defaults:
run:
shell: bash

# Allow this job to clone the repo and create a page deployment
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
process-schemas:
name: Process Schemas
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'recursive'
- name: Install just
uses: extractions/setup-just@v2
- name: Process directories
run: |
# List of directories to process
directories=("tbdex")
# Function to check if a directory is a submodule
is_submodule() {
local dir="$1"
if [ -f .gitmodules ] && git config --file .gitmodules --get "submodule.$dir.path" &> /dev/null; then
return 0
else
return 1
fi
}
# Process each directory
for dir in "${directories[@]}"; do
echo "Processing $dir"
if [ -d "$dir" ]; then
# Create the corresponding directory in hosted/
mkdir -p "hosted/$dir"
if is_submodule "$dir"; then
echo "$dir is a submodule"
(
cd "$dir"
just schemas
if [ -d ".schemas" ]; then
cp -R .schemas/* "../hosted/$dir/"
else
echo "Error: .schemas directory not found in $dir after running 'just schemas'"
exit 1 # This will cause the workflow to fail
fi
)
else
echo "$dir is not a submodule"
cp -R "$dir"/* "hosted/$dir/"
fi
else
echo "Error: $dir does not exist"
exit 1 # This will cause the workflow to fail
fi
done
- name: List contents of hosted directory
run: ls -R hosted

- name: Upload hosted directory
uses: actions/upload-pages-artifact@v3
with:
path: hosted

deploy:
needs: process-schemas
name: Deploy
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ignore everything in the hosted directory except the index.html file
/hosted/*
!/hosted/index.html
10 changes: 10 additions & 0 deletions hosted/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hosted Schemas</title>
</head>
<body>
</body>
</html>
2 changes: 1 addition & 1 deletion kcc
Submodule kcc updated 1 files
+0 −0 kcc.schema.json
2 changes: 1 addition & 1 deletion tbdex
Submodule tbdex updated 2 files
+2 −1 .gitignore
+16 −0 Justfile

0 comments on commit 40a35d9

Please sign in to comment.