CI/CD Workflow #14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CD Workflow | |
on: | |
push: | |
release: | |
types: | |
- published | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: "Environment to run deploy" | |
type: environment | |
required: true | |
force: | |
description: "Deploy even if tests fail" | |
type: boolean | |
required: false | |
default: false | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Run tests | |
run: | | |
echo "Mock testing..." | |
exit 1 # Simulate a failing test | |
deploy-to-staging: | |
needs: test | |
if: github.event_name == 'push' && github.ref_name == 'main' | |
concurrency: staging | |
uses: "./.github/workflows/deploy.yml" | |
with: | |
environment: staging | |
secrets: inherit | |
deploy-to-production: | |
needs: test | |
if: github.event_name == 'release' | |
concurrency: production | |
uses: "./.github/workflows/deploy.yml" | |
with: | |
environment: production | |
secrets: inherit | |
manual-deployment: | |
needs: test | |
if: github.event_name == 'workflow_dispatch' && (success() || inputs.force == true) | |
concurrency: ${{ inputs.environment }} | |
uses: "./.github/workflows/deploy.yml" | |
with: | |
environment: ${{ inputs.environment }} | |
secrets: inherit |