Skip to content

Commit

Permalink
move to v24 plugin structure
Browse files Browse the repository at this point in the history
  • Loading branch information
feederbox826 committed Dec 27, 2023
1 parent 25b29a7 commit 297b8e1
Show file tree
Hide file tree
Showing 12 changed files with 119 additions and 1 deletion.
51 changes: 51 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Deploy repository to Github Pages

on:
push:
branches: [ main ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout main
uses: actions/checkout@v4
with:
path: main
ref: main
fetch-depth: '0'
- run: |
cd main
./build_site.sh ../_site/develop
# uncomment this once we have a stable branch
# - name: Checkout Stable
# uses: actions/checkout@v2
# with:
# path: stable
# ref: stable
# fetch-depth: '0'
# - run: |
# cd stable
# ../master/build_site.sh ../_site/stable
- uses: actions/upload-pages-artifact@v4

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-22.04
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

67 changes: 67 additions & 0 deletions build_site.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash

# builds a repository of scrapers
# outputs to _site with the following structure:
# index.yml
# <scraper_id>.zip
# Each zip file contains the scraper.yml file and any other files in the same directory

outdir="$1"
if [ -z "$outdir" ]; then
outdir="_site"
fi

rm -rf "$outdir"
mkdir -p "$outdir"

buildPlugin()
{
f=$1
# get the scraper id from the directory
dir=$(dirname "$f")
plugin_id=$(basename "$f" .yml)

echo "Processing $plugin_id"

# create a directory for the version
version=$(git log -n 1 --pretty=format:%h -- "$dir"/*)
updated=$(TZ=UTC0 git log -n 1 --date="format-local:%F %T" --pretty=format:%ad -- "$dir"/*)

# create the zip file
# copy other files
zipfile=$(realpath "$outdir/$plugin_id.zip")

pushd "$dir" > /dev/null
zip -r "$zipfile" . > /dev/null
popd > /dev/null

name=$(grep "^name:" "$f" | head -n 1 | cut -d' ' -f2- | sed -e 's/\r//' -e 's/^"\(.*\)"$/\1/')
description=$(grep "^description:" "$f" | head -n 1 | cut -d' ' -f2- | sed -e 's/\r//' -e 's/^"\(.*\)"$/\1/')
ymlVersion=$(grep "^version:" "$f" | head -n 1 | cut -d' ' -f2- | sed -e 's/\r//' -e 's/^"\(.*\)"$/\1/')
version="$ymlVersion-$version"
dep=$(grep "^# requires:" "$f" | cut -c 12- | sed -e 's/\r//')

# write to spec index
echo "- id: $plugin_id
name: $name
metadata:
description: $description
version: $version
date: $updated
path: $plugin_id.zip
sha256: $(sha256sum "$zipfile" | cut -d' ' -f1)" >> "$outdir"/index.yml

# handle dependencies
if [ ! -z "$dep" ]; then
echo " requires:" >> "$outdir"/index.yml
for d in ${dep//,/ }; do
echo " - $d" >> "$outdir"/index.yml
done
fi

echo "" >> "$outdir"/index.yml
}

find ./plugins -mindepth 1 -name *.yml | while read file; do
buildPlugin "$file"
done
File renamed without changes.
2 changes: 1 addition & 1 deletion SHALookup.py → plugins/SHALookup/SHALookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
success_tag = config.success_tag if hasattr(config, 'success_tag') else "SHA: Match"
failure_tag = config.failure_tag if hasattr(config, 'failure_tag') else "SHA: No Match"

VERSION = "1.5.1"
VERSION = "1.6.0"
MAX_TITLE_LENGTH = 64

# pip modules
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 297b8e1

Please sign in to comment.