Skip to content

Commit a2a8873

Browse files
committed
Add deployment target parameter to docs
1 parent 88c58e4 commit a2a8873

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

.github/workflows/deploy.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ name: Deploy QIT Docs
22

33
on:
44
workflow_dispatch: # Allows manual triggering of the workflow.
5+
inputs:
6+
deploy_target:
7+
description: 'Deployment target'
8+
required: true
9+
default: 'staging'
10+
type: choice
11+
options:
12+
- staging
13+
- production
514
push:
615
branches:
716
- trunk
@@ -44,3 +53,4 @@ jobs:
4453
env:
4554
DOCS_SECRET: ${{ secrets.DOCS_SECRET }}
4655
FILE: ${{ github.workspace }}/docs.zip
56+
DEPLOY_TARGET: ${{ github.event.inputs.deploy_target || (github.ref == 'refs/heads/trunk' && 'production' || 'staging') }}

.github/workflows/scripts/deploy.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,20 @@
1616
throw new RuntimeException( sprintf( "File %s does not exist", getenv( 'FILE' ) ) );
1717
}
1818

19+
// Determine deployment target
20+
$deploy_target = getenv( 'DEPLOY_TARGET' ) ?: 'production';
21+
$deploy_urls = [
22+
'production' => 'https://qit.woo.com',
23+
'staging' => 'https://stagingcompatibilitydashboard.wpcomstaging.com',
24+
];
25+
26+
if ( ! isset( $deploy_urls[ $deploy_target ] ) ) {
27+
throw new RuntimeException( sprintf( "Invalid DEPLOY_TARGET '%s'. Must be 'production' or 'staging'", $deploy_target ) );
28+
}
29+
30+
$deploy_url = $deploy_urls[ $deploy_target ];
31+
echo sprintf( "🎯 Deploying to %s: %s\n", $deploy_target, $deploy_url );
32+
1933
$file = new SplFileObject( getenv( 'FILE' ) );
2034

2135
$chunk_size_bytes = 8 * 1024 * 1024; // 8mb
@@ -27,7 +41,7 @@
2741
$current_chunk ++;
2842
$curl = curl_init();
2943
$args = [
30-
CURLOPT_URL => 'https://qit.woo.com',
44+
CURLOPT_URL => $deploy_url,
3145
CURLOPT_POST => true,
3246
CURLOPT_RETURNTRANSFER => true,
3347
CURLOPT_FOLLOWLOCATION => true,

0 commit comments

Comments
 (0)