Skip to content

Deploy service a (refs/tags/a/v2023.13.0) to prod environment #6

Deploy service a (refs/tags/a/v2023.13.0) to prod environment

Deploy service a (refs/tags/a/v2023.13.0) to prod environment #6

Workflow file for this run

name: Deploy to Environment
run-name: Deploy service ${{ inputs.service_name}} (${{ inputs.checkout_ref || github.ref }}) to ${{ inputs.environment }} environment
on:
workflow_dispatch:
inputs:
service_name:
description: 'Service name'
required: true
type: choice
options:
- a
- b
environment:
description: 'Target deployment environment (dev, stage, prod)'
required: true
type: environment
workflow_call:
inputs:
checkout_ref:
required: true
type: string
service_name:
required: true
type: string
environment:
required: true
type: string
jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: ${{ inputs.environment }}
defaults:
run:
working-directory: services/${{ inputs.service_name }}/
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ inputs.checkout_ref || github.ref }}
- name: Check for successful tests
env:
GH_TOKEN: ${{ github.token }}
run: |
# Check if the checkout_ref has a successful test status
if ! gh api repos/${{ github.repository }}/commits/${{ inputs.checkout_ref || github.ref }}/check-runs | jq '.check_runs[] | select(.conclusion == "success")' > /dev/null; then
echo "No successful tests found for ${{ inputs.checkout_ref || github.ref }}"
exit 1
fi
- name: Deploy to environment
run: |
# Implement deployment steps based on the selected environment
echo "Deploying to ${{ inputs.environment }}"
./deploy.sh