This repository has been archived by the owner on Dec 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Frank Hinek <[email protected]>
- Loading branch information
1 parent
639943b
commit 40a35d9
Showing
5 changed files
with
114 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |