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: Pull Request Event

name: Pull Request Event

on:
  pull_request:
    branches:
      - main

jobs:
  create-environment:
    runs-on: ubuntu-latest
    steps:
      # Step 1: Checkout the repository
      - name: Checkout Code
        uses: actions/checkout@v3

      # Step 2: Set up dynamic environment name
      - name: Set Environment Name
        id: set-environment
        run: |
          # Generate a dynamic environment name based on PR number
          PR_NUMBER=$
          echo "environment-name=pr-${PR_NUMBER}" >> $GITHUB_ENV

      # Step 3: Deploy to the dynamically created environment
      - name: Deploy Application
        env:
          DEPLOY_ENV: $
        run: |
          echo "Deploying application to environment: $DEPLOY_ENV"
          # Add your deployment commands here