Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modular GitHub Actions #189

Open
ngupta23 opened this issue Oct 28, 2024 · 0 comments
Open

Modular GitHub Actions #189

ngupta23 opened this issue Oct 28, 2024 · 0 comments

Comments

@ngupta23
Copy link
Owner

If you want to create a base GitHub action files and run it with different settings, you can do this using reusable calls as follows

# modular_workflow_file.yaml
name: Modular Workflow File using flag1

on:
  workflow_call:
    inputs:
      flag1:
        required: true
        type: boolean

env:
  ENV_VAR1: ${{ secrets.ENV_VAR1 }}
  ENV_VAR2: ${{ secrets.ENV_VAR2 }}

jobs:
  my_job_name:
    runs-on: ubuntu-latest
    steps:
      - name: Clone repo
        uses: actions/checkout@v3

      - name: Set up environment
        uses: actions/setup-python@v4
        with:
          python-version: "3.10"

      - name: Install pip requirements
        run: pip install uv && uv pip install -e . --system

      - name: Run file
        run: |
          echo "Running with --flag1=${{ inputs.flag1}}"
          python my_lib/folder1/script1 --flag1=${{ inputs.flag1}}
# calling workflow file
name: Workflow using settings True

on:
  schedule:
    - cron: "0 0 * * *"  # Runs every day at midnight
  workflow_dispatch:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  call_reusable:
    uses: ./.github/workflows/modular_workflow_file.yaml
    with:
      flag1: True
    secrets: inherit  # Passes all secrets to the reusable workflow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant