Create datacentre-shutdown.md #24
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: Trigger Build Workflow | |
on: | |
push: | |
branches: ["main"] | |
workflow_dispatch: | |
inputs: | |
target_service: | |
description: 'Input a service name (e.g., demo-app)' | |
required: true | |
target_version: | |
description: 'Input a version (e.g., v1.0.0)' | |
required: true | |
jobs: | |
trigger: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Trigger Workflow in Main Repository | |
env: | |
GH_TOKEN: ${{ secrets.PAT }} | |
run: | | |
# Set the required variables | |
repo_owner="Hacking-and-Coffee" | |
repo_name="hackingandcoffee-site" | |
event_type="trigger-workflow" | |
# Handle both push and workflow_dispatch events | |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
service="${{ github.event.inputs.target_service }}" | |
version="${{ github.event.inputs.target_version }}" | |
else | |
service="theme" | |
version="${{ github.sha }}" | |
fi | |
echo "Triggering workflow for service: $service, version: $version" | |
curl -v -L \ | |
-X POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${GH_TOKEN}" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
https://api.github.com/repos/$repo_owner/$repo_name/dispatches \ | |
-d "{\"event_type\": \"$event_type\", \"client_payload\": {\"service\": \"$service\", \"version\": \"$version\", \"unit\": false, \"integration\": true}}" | |