feat: Commit static files to variable branch

This commit is contained in:
oSumAtrIX 2023-10-30 00:19:59 +01:00
parent c0c91db2df
commit 915db07c72
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
2 changed files with 10 additions and 6 deletions

View File

@ -3,6 +3,10 @@ name: Update static files
on:
repository_dispatch:
workflow_dispatch:
inputs:
output-branch:
descripton: "Branch to push static files to"
required: true
jobs:
update:
@ -24,7 +28,7 @@ jobs:
- name: Check if a deployment exists
run: |
if git ls-remote --exit-code --heads origin gh-pages; then
if git ls-remote --exit-code --heads origin ${{ inputs.output-branch }}; then
echo "::set-output name=deployment-exists::true"
else
echo "::set-output name=deployment-exists::false"
@ -36,12 +40,12 @@ jobs:
run: |
git config user.name revanced-bot
git config user.email github@revanced.app
git subtree add --prefix=static/ origin/gh-pages --squash
git subtree add --prefix=static/ origin/${{ inputs.output-branch }} --squash
- name: Update static files
run: |
pip install requests
python src/main.py
poetry install
poetry run python main.py
- name: Commit changes
uses: EndBug/add-and-commit@v9
@ -54,6 +58,6 @@ jobs:
uses: s0/git-publish-subdir-action@develop
env:
REPO: self
BRANCH: gh-pages
BRANCH: ${{ inputs.output-branch }}
FOLDER: static
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -4,7 +4,7 @@ Repository to host a static API using GitHub workflows.
## How it works
When CI is ran, static files are generated and commited to the `gh-pages` branch.
When CI is ran, static files are generated and commited to the specified branch.
The file `generator.py` provides a list of static file generator classes. Each class has a name.
The configuration file `config.json` is read which contains the configuration for the API.
By specifying the name of the generator in the `generators` array of the configuration, the corresponding generator will be used. The current object of the configuration is passed to the generator.