GitHub Actions Workshop

Master GitHub Actions with hands-on labs and exercises. Learn how to automate workflows, run tests, deploy applications, and more using GitHub's powerful automation platform. This repository has everything you need to get started with continuous integration and continuous deployment.


Project maintained by prasadhonrao Hosted on GitHub Pages — Theme by mattgraham

Solution: Environment Variables and Secrets

name: Env Var and Secrets

on:
  workflow_dispatch:
  push:
    paths:
      - '.github/workflows/env-var-secrets.yml'

jobs:
  print:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        environment: [dev, prod]

    environment: $

    steps:
      - name: Display Environment Variable
        run: |
          echo "Building for environment: $"
          echo "ENVIRONMENT_NAME: $ENVIRONMENT"
          echo "ENVIRONMENT_NAME length: ${#ENVIRONMENT}"
          echo "ENVIRONMENT_NAME (partial): ${ENVIRONMENT:0:5}..."
        env:
          ENVIRONMENT: $

      - name: Display Environment Secret
        run: |
          echo "SECRET length: ${#SECRET}"
        env:
          SECRET: $

      - name: Display Repository Variable
        run: |
          echo "REPOSITORY_VARIABLE: $"