44 lines
1.2 KiB
YAML
44 lines
1.2 KiB
YAML
name: Config Provider Library
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
config_path:
|
|
required: true
|
|
type: string
|
|
secrets:
|
|
GITEA_TOKEN:
|
|
required: true
|
|
GIT_PAGES_PUBLISH_TOKEN:
|
|
required: true
|
|
outputs:
|
|
env_json:
|
|
value: ${{ jobs.parse-config.outputs.json_data }}
|
|
|
|
env:
|
|
GITEA_API_URL: ${{ fromJson(jobs.parse-config.outputs.json_data).GITEA_API_URL }}
|
|
PAGES_HOST: ${{ fromJson(jobs.parse-config.outputs.json_data).PAGES_HOST }}
|
|
GIT_PAGES_PUBLISH_URL: ${{ fromJson(jobs.parse-config.outputs.json_data).GIT_PAGES_PUBLISH_URL }}
|
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
GIT_PAGES_PUBLISH_TOKEN: ${{ secrets.GIT_PAGES_PUBLISH_TOKEN }}
|
|
|
|
jobs:
|
|
parse-config:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
json_data: ${{ steps.convert.outputs.JSON_OUT }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- id: convert
|
|
run: |
|
|
JSON_STRING=$(jq -R -s '
|
|
split("\n")
|
|
| map(select(length > 0 and (startswith("#") | not)))
|
|
| map(split("="))
|
|
| map({(.[0]): .[1]})
|
|
| add
|
|
' "${{ inputs.config_path }}")
|
|
|
|
CLEAN_JSON=$(echo "$JSON_STRING" | jq -c .)
|
|
echo "JSON_OUT=$CLEAN_JSON" >> "$GITHUB_OUTPUT"
|