From 915db07c72939c10c2c7de92507a7a612070a26c Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Mon, 30 Oct 2023 00:19:59 +0100 Subject: [PATCH] feat: Commit static files to variable branch --- .github/workflows/update.yml | 14 +++++++++----- README.md | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index ef8143f..81c76ee 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -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 }} diff --git a/README.md b/README.md index 05b71b0..4f95d9c 100644 --- a/README.md +++ b/README.md @@ -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.