๐ŸŒ Detecting your locationโ€ฆ

Erweiterte GitHub-Aktionen 2026: Wiederverwendbare Workflows, OIDC und dynamische Matrizen

โฑ๏ธ2 min read  ยท  349 words
Advanced GitHub Actions 2026: Reusable Workflows, OIDC and Dynamic Matrices

รœber grundlegendes CI hinaus,GitHub-Aktionenunterstรผtzt wiederverwendbare Workflows, zusammengesetzte Aktionen, dynamische Matrizen und OIDC-Authentifizierung. Dieser Leitfaden behandelt fortgeschrittene Muster, die von Entwicklungsteams im Jahr 2026 im groรŸen MaรŸstab verwendet werden.

Wiederverwendbare Arbeitsablรคufe

# .github/workflows/reusable-test.yml
on:
  workflow_call:
    inputs:
      python-version:
        required: true
        type: string
    secrets:
      codecov-token:
        required: true

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: ${{ inputs.python-version }}
      - run: pip install -r requirements.txt && pytest --cov

# Caller workflow
jobs:
  run-tests:
    uses: ./.github/workflows/reusable-test.yml
    with:
      python-version: '3.12'
    secrets:
      codecov-token: ${{ secrets.CODECOV_TOKEN }}

Dynamische Matrix (zur Laufzeit generiert)

jobs:
  generate-matrix:
    runs-on: ubuntu-latest
    outputs:
      matrix: ${{ steps.set-matrix.outputs.matrix }}
    steps:
      - uses: actions/checkout@v4
      - id: set-matrix
        run: |
          SERVICES=$(ls services/ | jq -R -s -c 'split("n")[:-1]')
          echo "matrix={"service":$SERVICES}" >> $GITHUB_OUTPUT

  build:
    needs: generate-matrix
    strategy:
      matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: docker build services/${{ matrix.service }}

OIDC-Authentifizierung (keine langlebigen Geheimnisse)

Verwenden Sie OIDC, um ein kurzlebiges GitHub-Token gegen Cloud-Anmeldeinformationen auszutauschen. Keine gespeicherten Geheimnisse erforderlich.

permissions:
  id-token: write
  contents: read

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Configure AWS (OIDC)
        uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: arn:aws:iam::123456789:role/GitHubActionsRole
          aws-region: us-east-1
      - run: aws ecs update-service --cluster prod --service myapp --force-new-deployment

Umweltschutzvorschriften

jobs:
  staging:
    environment: staging
    runs-on: ubuntu-latest
    steps:
      - run: ./deploy.sh staging

  production:
    environment: production  # requires manual approval
    needs: staging
    runs-on: ubuntu-latest
    steps:
      - run: ./deploy.sh production

Zusammengesetzte Aktionen

# .github/actions/setup-project/action.yml
name: Setup Project
inputs:
  python-version:
    default: '3.12'
runs:
  using: composite
  steps:
    - uses: actions/setup-python@v5
      with:
        python-version: ${{ inputs.python-version }}
    - uses: actions/cache@v4
      with:
        path: ~/.cache/pip
        key: pip-${{ hashFiles('requirements.txt') }}
    - run: pip install -r requirements.txt
      shell: bash

Fazit

Wiederverwendbare Workflows verhindern Duplikate zwischen Repos. Durch OIDC entfรคllt die Notwendigkeit, langlebige Cloud-Anmeldeinformationen als Geheimnisse zu speichern. Umweltschutzvorschriften sehen vor, dass Produktionseinsรคtze der Zustimmung des Menschen unterliegen. Diese drei Muster sind fรผr jedes Ingenieurteam im Jahr 2026 unverzichtbar.

MD Rafikul Islam

Written by

MD Rafikul Islam is a software developer and the editor of TechPulse. He writes about developer tooling, hardware, and the practical decisions that come up in day-to-day engineering work โ€” which laptop to buy, which framework to commit to, why a build broke at 2am. He tests the tools he writes about and says plainly when something is not worth the money. Corrections and corrections requests are welcome at rony.yf25@gmail.com.

โœ๏ธ Leave a Comment

Your email address will not be published. Required fields are marked *

๐ŸŒ Read in:๐Ÿ‡ฌ๐Ÿ‡ง English๐Ÿ‡ฉ๐Ÿ‡ช Deutsch๐Ÿ‡ง๐Ÿ‡ท Portuguรชs๐Ÿ‡ธ๐Ÿ‡ฆ ุงู„ุนุฑุจูŠุฉ๐Ÿ‡ฎ๐Ÿ‡ณ เคนเคฟเคจเฅเคฆเฅ€๐Ÿ‡ง๐Ÿ‡ฉ เฆฌเฆพเฆ‚เฆฒเฆพ