Centralize deploy_path, environment and artifact name/path as workflow variables

Co-authored-by: Junie <junie@jetbrains.com>
This commit is contained in:
2026-07-24 16:24:20 +02:00
co-authored by Junie
parent 3e537162c0
commit f47aed55c7
5 changed files with 58 additions and 25 deletions
+35 -15
View File
@@ -7,16 +7,37 @@ on:
branches: [master]
# Herbruikbare instellingen voor deze workflow. Pas deze aan op één plek als
# de Node/pnpm-versie wijzigt. Let op: de env-context is NIET beschikbaar in
# de `with:`-inputs van een aangeroepen reusable workflow (zie de deploy-test
# job hieronder), dat is een beperking van GitHub/Gitea Actions zelf, dus
# ARTIFACT_NAME/DEPLOY_ENVIRONMENT/DEPLOY_PATH blijven daar noodgedwongen
# letterlijk in de `with:`-sectie staan.
# de Node/pnpm-versie, de artifact-naam/pad of de testdeploy-bestemming
# wijzigt. Let op: de env-context is NIET beschikbaar in de `with:`-inputs
# van een aangeroepen reusable workflow (zie de `config`-job hieronder, die
# dit oplost door deze waarden via job-outputs door te geven aan de
# `deploy-test`-job).
env:
NODE_VERSION: '20'
PNPM_VERSION: '9'
ARTIFACT_NAME: dist
ARTIFACT_PATH: dist/
DEPLOY_ENVIRONMENT: test
DEPLOY_PATH: /html/test/slpsoftware
jobs:
# Geeft de env-variabelen hierboven door als job-outputs, zodat ze ook
# gebruikt kunnen worden in de `with:`-sectie van de `deploy-test`-job
# hieronder (waar de env-context zelf niet beschikbaar is, omdat dat een
# aanroep naar een reusable workflow is).
config:
runs-on: ubuntu-latest
outputs:
artifact_name: ${{ steps.set.outputs.artifact_name }}
deploy_environment: ${{ steps.set.outputs.deploy_environment }}
deploy_path: ${{ steps.set.outputs.deploy_path }}
steps:
- id: set
run: |
echo "artifact_name=${{ env.ARTIFACT_NAME }}" >> "$GITHUB_OUTPUT"
echo "deploy_environment=${{ env.DEPLOY_ENVIRONMENT }}" >> "$GITHUB_OUTPUT"
echo "deploy_path=${{ env.DEPLOY_PATH }}" >> "$GITHUB_OUTPUT"
prepare:
runs-on: ubuntu-latest
steps:
@@ -76,8 +97,8 @@ jobs:
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: dist
path: dist/
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_PATH }}
retention-days: 1
test:
@@ -114,15 +135,14 @@ jobs:
run: pnpm run test
deploy-test:
needs: [build, test]
needs: [build, test, config]
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/master')
uses: ./.gitea/workflows/deploy.yaml
secrets: inherit
# Let op: deze waarden kunnen hier NIET via het `env:`-blok bovenaan dit
# bestand worden gezet - de env-context is niet beschikbaar in de
# `with:`-sectie van een aangeroepen reusable workflow (beperking van
# GitHub/Gitea Actions zelf). Pas deze waarden dus rechtstreeks hier aan.
# Deze waarden komen uit het `env:`-blok bovenaan dit bestand, via de
# `config`-job (die ze doorgeeft als job-outputs). Pas de waarden dus aan
# in het `env:`-blok, niet hier.
with:
artifact_name: dist
environment: test
deploy_path: /html/test/slpsoftware
artifact_name: ${{ needs.config.outputs.artifact_name }}
environment: ${{ needs.config.outputs.deploy_environment }}
deploy_path: ${{ needs.config.outputs.deploy_path }}