-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathaction.yml
84 lines (78 loc) · 3.56 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: 'Deploy app to Shopify Oxygen'
branding:
icon: shopping-bag
colour: green
description: 'Deploy JavaScript applications to Shopify Oxygen directly from GitHub'
inputs:
build_command:
description: The build command to execute; OXYGEN_ASSET_BASE_URL is available as a reference to Shopify's CDN for this command
required: true
commit_message:
description: The message of the commit
default: ${{ github.event.head_commit.message }}
required: true
commit_timestamp:
description: The timestamp of the commit
default: ${{ github.event.head_commit.timestamp }}
required: true
oxygen_deployment_token:
description: The JWT deployment token
required: true
deprecationMessage: The shopify/oxygenctl-action is being deprecated and all merchants are encouraged to migrate to the Hydrogen CLI deploy command. To use the deploy command, upgrade your Hydrogen project to use Hydrogen CLI v7.0.0 or later. See our example GitHub workflow https://shopify.dev/docs/custom-storefronts/hydrogen/deployments/github#oxygen-github-action
oxygen_worker_dir:
description: The name of the directory containing the worker file
default: dist/worker
oxygen_client_dir:
description: The name of the directory with compiled client files
default: dist/client
oxygen_deployment_verification:
description: Verify the worker deployment to Oxygen has been completed (`true` or `false`)
default: true
oxygen_deployment_verification_max_duration:
description: The maximum duration in seconds to wait for the health check to pass
default: 180
path:
description: The root path of the project to deploy
outputs:
url:
description: URL of the deployment
value: ${{ steps.oxygen-cli-action.outputs.url }}
auth_bypass_token:
description: An auth bypass token used for end-to-end testing
value: ${{ steps.oxygen-cli-action.outputs.auth_bypass_token }}
runs:
using: 'composite'
steps:
- name: Collect metrics
shell: 'bash'
run: |
endpoint="https://metrics.myshopify.dev"
metric='{"events":[{"name": "oxygen_platform.oxygenctl_action_usage", "type": "count", "value": 1}]}'
curl -s -X POST -H "Content-Type: application/json" -d "$metric" "$endpoint"
- name: Build and Publish to Oxygen
shell: 'bash'
id: 'oxygen-cli-action'
env:
NODE_ENV: production
run: |
echo "Deploying to Oxygen..."
build_command_filtered=$(echo '${{ inputs.build_command }}' | sed 's/HYDROGEN_ASSET_BASE_URL=$OXYGEN_ASSET_BASE_URL //g')
oxygen_command="npm exec --package=@shopify/[email protected] --package=@shopify/[email protected] -- oxygen-cli oxygen:deploy \
--path=${{ inputs.path }} \
--assetsFolder=${{ inputs.oxygen_client_dir }} \
--workerFolder=${{ inputs.oxygen_worker_dir }} \
--verificationMaxDuration=${{ inputs.oxygen_deployment_verification_max_duration }} \
--token=${{ inputs.oxygen_deployment_token }}"
if [ "${{ inputs.oxygen_deployment_verification }}" == "false" ]; then
oxygen_command+=" --skipVerification"
fi
output=$($oxygen_command --buildCommand="${build_command_filtered}")
exit_code=$?
if [ $exit_code -ne 0 ]; then
exit $exit_code
fi
echo "url=$(jq -r '.url' <<<"$output")" >> "$GITHUB_OUTPUT"
has_token=$(jq 'has("authBypassToken")' <<<"$output")
if [ "$has_token" == 'true' ]; then
echo "auth_bypass_token=$(jq -r '.authBypassToken' <<<"$output")" >> "$GITHUB_OUTPUT"
fi