-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (81 loc) · 2.97 KB
/
mrt-deploy.yml
File metadata and controls
91 lines (81 loc) · 2.97 KB
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
85
86
87
88
89
90
91
name: Deploy to MRT
# This workflow automatically deploys your storefront to Managed Runtime (MRT)
# when changes are pushed to the main branch or when manually triggered.
#
# ⚠️ FOR TESTING: Make sure to set up GitHub secrets:
# - MRT_CLIENT_USER
# - MRT_CLIENT_API_KEY
# Optional variables: MRT_TARGET, MRT_PROJECT, MRT_ORIGIN
on:
push:
branches:
- 'main'
workflow_dispatch:
inputs:
environment:
type: environment
description: Select the environment to deploy to
required: false
target:
type: string
description: MRT target environment (overrides MRT_TARGET variable)
required: false
message:
type: string
description: The message to set for the deployed bundle
required: false
env:
NODE_VERSION: '24'
PNPM_VERSION: '10.28.0'
CREDENTIALS_FILE_PATH: '~/.mobify'
DEFAULT_MESSAGE: 'build ${{ github.run_id }} on ${{ github.ref }} - ${{ github.sha }}'
jobs:
check-deploy:
runs-on: ubuntu-latest
steps:
- name: Log deploy skip
if: ${{ secrets.MRT_CLIENT_API_KEY == '' }}
run: |
echo "::notice title=Deploy skipped::Deploy job was skipped because MRT_CLIENT_API_KEY is not set. Configure the secret in repository settings to enable deploys."
deploy:
needs: check-deploy
if: ${{ secrets.MRT_CLIENT_API_KEY != '' }}
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment || 'Production' }}
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build Bundle
uses: './.github/actions/build-bundle'
with:
node-version: ${{ env.NODE_VERSION }}
pnpm-version: ${{ env.PNPM_VERSION }}
- name: Create MRT credentials file
id: create_mrt_credentials
uses: './.github/actions/set_mrt_credentials'
with:
MRT_USER: ${{ secrets.MRT_CLIENT_USER }}
MRT_API_KEY: ${{ secrets.MRT_CLIENT_API_KEY }}
CREDENTIALS_FILE_PATH: ${{ env.CREDENTIALS_FILE_PATH }}
- name: Push to MRT
uses: './.github/actions/push_to_mrt'
with:
TARGET: ${{ github.event.inputs.target || vars.MRT_TARGET || 'production' }}
CLOUD_ORIGIN: ${{ vars.MRT_ORIGIN || 'https://cloud.mobify.com' }}
FLAGS: '--wait'
PROJECT: ${{ vars.MRT_PROJECT || '' }}
MESSAGE: ${{ github.event.inputs.message || github.event.head_commit.message || env.DEFAULT_MESSAGE }}
CREDENTIALS_FILE_PATH: ${{ env.CREDENTIALS_FILE_PATH }}
- name: Cleanup MRT credentials file
run: |
CREDENTIALS_PATH="${{ env.CREDENTIALS_FILE_PATH }}"
if [[ "$CREDENTIALS_PATH" == ~* ]]; then
CREDENTIALS_PATH="${CREDENTIALS_PATH/#\~/$HOME}"
fi
if [ -f "$CREDENTIALS_PATH" ]; then
rm -f "$CREDENTIALS_PATH"
echo "🧹 Cleaned up credentials file: $CREDENTIALS_PATH"
fi
shell: bash
if: always()