name: Secrets And Variables

on:
  workflow_dispatch:

jobs:
  build-and-deploy:
    runs-on: ubuntu-22.04

    env:
      DEPLOYMENT_ENV: 'production'  # Define a workflow-level environment variable

    steps:
      - name: Build
        run: | # Build your application here
          echo "Building the application"
          echo "API_KEY: ${{ secrets.API_KEY }}"
          echo $SECRET_API_KEY
          echo "DEPLOYMENT_ENV: ${{ env.DEPLOYMENT_ENV }}"
          echo $CONFIG_VARIABLE
          echo "USERNAME: ${{ vars.USERNAME }}"
          echo $STEPS_USERNAME
        env:
          SECRET_API_KEY: ${{ secrets.API_KEY }}        # Access a secret as an environment variable
          STEPS_USERNAME: ${{ vars.USERNAME }}
          CONFIG_VARIABLE: ${{ env.DEPLOYMENT_ENV }}    # Use a workflow-level environment variable

      - name: Deploy
        run: | # Deploy your application using the secrets and variables
          echo "Global job variable ${{ env.DEPLOYMENT_ENV }}"
          echo "Variable from this step ${CONFIG_VARIABLE2} environment"
          echo "Local step variable ${ANOTHER_VARIABLE}"
          echo "Secret print ${{ secrets.API_KEY }}"
          echo "Step's secret variable ${SECRET_API_KEY}"
        env:
          SECRET_API_KEY: ${{ secrets.API_KEY }}
          CONFIG_VARIABLE2: ${{ env.DEPLOYMENT_ENV }}  # Use a workflow-level environment variable
          ANOTHER_VARIABLE: 'some value'               # Define a variable directly in the workflow
