Deploy service a (a/v2023.10.3) to dev environment #8
Workflow file for this run
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: Deploy to Environment With Check | |
run-name: Deploy service ${{ inputs.service_name}} (${{ inputs.checkout_ref }}) to ${{ inputs.environment }} environment | |
on: | |
workflow_dispatch: | |
inputs: | |
checkout_ref: | |
description: 'Git tag' | |
required: true | |
service_name: | |
description: 'Service name' | |
required: true | |
type: choice | |
options: | |
- a | |
- b | |
environment: | |
description: 'Target deployment environment (dev, stage, prod)' | |
required: true | |
type: choice | |
options: | |
- dev | |
- stage | |
- prod | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
environment: | |
name: ${{ github.event.inputs.environment }} | |
defaults: | |
run: | |
working-directory: services/${{ inputs.service_name }}/ | |
steps: | |
- 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/${{ github.event.inputs.checkout_ref }}/check-runs | jq '.check_runs[] | select(.conclusion == "success")' > /dev/null; then | |
echo "No successful tests found for ${{ github.event.inputs.checkout_ref }}" | |
exit 1 | |
fi | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.inputs.checkout_ref }} | |
- name: Deploy to environment | |
run: | | |
# Implement deployment steps based on the selected environment | |
echo "Deploying to ${{ github.event.inputs.environment }}" | |
./deploy.sh |