esitellään env conf tiedosto
This commit is contained in:
@@ -2,23 +2,26 @@ name: Build Feature
|
|||||||
on:
|
on:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
inputs:
|
inputs:
|
||||||
|
env_json:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
bats-image:
|
bats-image:
|
||||||
required: false
|
required: true
|
||||||
type: string
|
type: string
|
||||||
default: bats/bats:latest
|
|
||||||
cucumber-node-image:
|
cucumber-node-image:
|
||||||
required: false
|
required: true
|
||||||
type: string
|
type: string
|
||||||
default: node:22
|
|
||||||
|
env:
|
||||||
|
GITEA_API_URL: ${{ fromJson(inputs.env_json).GITEA_API_URL }}
|
||||||
|
PAGES_HOST: ${{ fromJson(inputs.env_json).PAGES_HOST }}
|
||||||
|
GIT_PAGES_PUBLISH_URL: ${{ fromJson(inputs.env_json).GIT_PAGES_PUBLISH_URL }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
bats:
|
bats:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
GITEA_API_URL: https://gitea.app.keskikuja.site
|
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
PAGES_HOST: ci-reports.helm-dev.keskikuja.site
|
|
||||||
GIT_PAGES_PUBLISH_URL: https://ci-reports.helm-dev.keskikuja.site
|
|
||||||
GIT_PAGES_PUBLISH_TOKEN: ${{ secrets.GIT_PAGES_PUBLISH_TOKEN }}
|
GIT_PAGES_PUBLISH_TOKEN: ${{ secrets.GIT_PAGES_PUBLISH_TOKEN }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@@ -80,10 +83,7 @@ jobs:
|
|||||||
container:
|
container:
|
||||||
image: ${{ inputs.cucumber-node-image }}
|
image: ${{ inputs.cucumber-node-image }}
|
||||||
env:
|
env:
|
||||||
GITEA_API_URL: https://gitea.app.keskikuja.site
|
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
PAGES_HOST: ci-reports.helm-dev.keskikuja.site
|
|
||||||
GIT_PAGES_PUBLISH_URL: https://ci-reports.helm-dev.keskikuja.site
|
|
||||||
GIT_PAGES_PUBLISH_TOKEN: ${{ secrets.GIT_PAGES_PUBLISH_TOKEN }}
|
GIT_PAGES_PUBLISH_TOKEN: ${{ secrets.GIT_PAGES_PUBLISH_TOKEN }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@@ -153,10 +153,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [bats, cucumber]
|
needs: [bats, cucumber]
|
||||||
env:
|
env:
|
||||||
GITEA_API_URL: https://gitea.app.keskikuja.site
|
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
PAGES_HOST: ci-reports.helm-dev.keskikuja.site
|
|
||||||
GIT_PAGES_PUBLISH_URL: https://ci-reports.helm-dev.keskikuja.site
|
|
||||||
GIT_PAGES_PUBLISH_TOKEN: ${{ secrets.GIT_PAGES_PUBLISH_TOKEN }}
|
GIT_PAGES_PUBLISH_TOKEN: ${{ secrets.GIT_PAGES_PUBLISH_TOKEN }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|||||||
+13
-2
@@ -5,16 +5,27 @@ on:
|
|||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
load-config:
|
||||||
|
uses: niko/gitea-ci-library/.gitea/workflows/config-provider.yml@plan/0003-alkaa-käyttämään-itseään-commit-raportti
|
||||||
|
with:
|
||||||
|
config_path: feature-env.conf
|
||||||
|
|
||||||
feature:
|
feature:
|
||||||
if: github.ref != 'refs/heads/main'
|
if: github.ref != 'refs/heads/main'
|
||||||
uses: niko/gitea-ci-library/.gitea/workflows/build-feature.yml@main
|
needs: [load-config]
|
||||||
|
uses: niko/gitea-ci-library/.gitea/workflows/build-feature.yml@plan/0003-alkaa-käyttämään-itseään-commit-raportti
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
with:
|
with:
|
||||||
|
env_json: ${{ needs.load-config.outputs.env_json }}
|
||||||
bats-image: bats/bats:latest
|
bats-image: bats/bats:latest
|
||||||
|
cucumber-node-image: node:22
|
||||||
|
|
||||||
main:
|
main:
|
||||||
if: github.ref == 'refs/heads/main'
|
if: github.ref == 'refs/heads/main'
|
||||||
uses: niko/gitea-ci-library/.gitea/workflows/build-feature.yml@main
|
needs: [load-config]
|
||||||
|
uses: niko/gitea-ci-library/.gitea/workflows/build-feature.yml@plan/0003-alkaa-käyttämään-itseään-commit-raportti
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
with:
|
with:
|
||||||
|
env_json: ${{ needs.load-config.outputs.env_json }}
|
||||||
bats-image: bats/bats:latest
|
bats-image: bats/bats:latest
|
||||||
|
cucumber-node-image: node:22
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
name: Config Provider Library
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
config_path:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
outputs:
|
||||||
|
env_json:
|
||||||
|
value: ${{ jobs.parse-config.outputs.json_data }}
|
||||||
|
|
||||||
|
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"
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
GITEA_API_URL: https://gitea.app.keskikuja.site
|
|
||||||
PAGES_HOST: ci-reports.helm-dev.keskikuja.site
|
|
||||||
GIT_PAGES_PUBLISH_URL: https://ci-reports.helm-dev.keskikuja.site
|
|
||||||
@@ -50,6 +50,27 @@ Käytäntö:
|
|||||||
- Jos `docker run` tarvitsee env-arvoja, välitä ne eksplisiittisesti `-e VAR`-lipulla
|
- Jos `docker run` tarvitsee env-arvoja, välitä ne eksplisiittisesti `-e VAR`-lipulla
|
||||||
- `GITHUB_ENV` on validi tapa välittää arvoja stepien välille samassa jobissa, mutta ei leviä `docker run`-kontteihin ilman `-e`-lippua
|
- `GITHUB_ENV` on validi tapa välittää arvoja stepien välille samassa jobissa, mutta ei leviä `docker run`-kontteihin ilman `-e`-lippua
|
||||||
|
|
||||||
|
### Cross-job config propagation (validated 2026-06-13)
|
||||||
|
|
||||||
|
Workflow `env:` on ainoa natiivi mekanismi, joka tekee arvoista näkyviä kaikissa jobeissa automaattisesti. Ketju:
|
||||||
|
|
||||||
|
```
|
||||||
|
feature-env.conf → config-provider.yml → env_json (single JSON string output)
|
||||||
|
↓
|
||||||
|
ci.yml with: env_json
|
||||||
|
↓
|
||||||
|
build-feature.yml workflow env:
|
||||||
|
fromJson(inputs.env_json).KEY
|
||||||
|
↓
|
||||||
|
kaikki jobit → $KEY
|
||||||
|
```
|
||||||
|
|
||||||
|
Avainkomponentit:
|
||||||
|
- **config-provider.yml** — reusable workflow, lukee conf-tiedoston → yksi JSON output
|
||||||
|
- **`needs` + `with:`** — `jobs.<job_id>.with` tukee `needs`-kontekstia, joten `${{ needs.load-config.outputs.env_json }}` toimii
|
||||||
|
- **workflow `env:`** — ainoa tapa jakaa arvot kaikkiin jobeihin. `fromJson(inputs.env_json).KEY` purkaa yksittäiset arvot
|
||||||
|
- **Per-job `env:`** — sisältää vain secretit (`GITEA_TOKEN`, `GIT_PAGES_PUBLISH_TOKEN`), ei config-arvoja
|
||||||
|
|
||||||
## 5. Pipeline Provides All Dependencies
|
## 5. Pipeline Provides All Dependencies
|
||||||
|
|
||||||
- Ei luottamusta runnerin esiasennettuihin työkaluihin
|
- Ei luottamusta runnerin esiasennettuihin työkaluihin
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
GITEA_API_URL=https://gitea.app.keskikuja.site
|
||||||
|
PAGES_HOST=ci-reports.helm-dev.keskikuja.site
|
||||||
|
GIT_PAGES_PUBLISH_URL=https://ci-reports.helm-dev.keskikuja.site
|
||||||
Reference in New Issue
Block a user