-
Notifications
You must be signed in to change notification settings - Fork 6
94 lines (80 loc) · 3.28 KB
/
deploy.yml
File metadata and controls
94 lines (80 loc) · 3.28 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
92
93
name: Deploy to Motia Cloud
on:
push:
branches:
- main
workflow_dispatch:
inputs:
versionName:
description: 'Version Name to deploy (e.g., v1.2.0)'
required: false
versionDescription:
description: 'Version Description to deploy'
required: false
env:
# API Key stored as GitHub Secret (NEVER commit API keys to code)
MOTIA_API_KEY: ${{ secrets.MOTIA_API_KEY }}
# Project name in Motia Cloud
MOTIA_PROJECT_NAME: git-history
# Environment ID from Motia Cloud dashboard (Settings tab)
MOTIA_ENV_ID: ${{ secrets.MOTIA_ENV_ID }}
jobs:
deploy:
name: Deploy to Motia Cloud
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for commit count
- name: Generate Version Number
id: version
run: |
# Get commit count for incremental versioning
COMMIT_COUNT=$(git rev-list --count HEAD)
# Calculate version: major.minor.patch based on commit count
MAJOR=1
MINOR=$((COMMIT_COUNT / 100))
PATCH=$((COMMIT_COUNT % 100))
AUTO_VERSION="v${MAJOR}.${MINOR}.${PATCH}"
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ github.event.inputs.versionName }}" ]; then
echo "VERSION_NAME=${{ github.event.inputs.versionName }}" >> $GITHUB_ENV
echo "VERSION_DESCRIPTION=${{ github.event.inputs.versionDescription || github.event.head_commit.message }}" >> $GITHUB_ENV
else
echo "VERSION_NAME=${AUTO_VERSION}" >> $GITHUB_ENV
echo "VERSION_DESCRIPTION=${{ github.event.head_commit.message }}" >> $GITHUB_ENV
fi
echo "Generated version: ${AUTO_VERSION}"
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: 'package-lock.json'
- name: Install dependencies
run: npm ci
- name: Generate types
run: npx motia generate-types
- name: Create Env file from Secrets
run: |
# Create .env file from GitHub Secrets (secure way to pass env vars)
echo "GITHUB_TOKEN=${{ secrets.GH_TOKEN }}" > .env
# Add any other environment variables your app needs here
# echo "OTHER_VAR=${{ secrets.OTHER_VAR }}" >> .env
- name: Deploy to Motia Cloud
run: |
npx motia cloud deploy \
--api-key ${{ env.MOTIA_API_KEY }} \
--project-name ${{ env.MOTIA_PROJECT_NAME }} \
--environment-id ${{ env.MOTIA_ENV_ID }} \
--version-name "${{ env.VERSION_NAME }}" \
--version-description "${{ env.VERSION_DESCRIPTION }}" \
--env-file .env
- name: Deployment Summary
run: |
echo "## 🚀 Deployment Complete" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Version:** ${{ env.VERSION_NAME }}" >> $GITHUB_STEP_SUMMARY
echo "- **Description:** ${{ env.VERSION_DESCRIPTION }}" >> $GITHUB_STEP_SUMMARY
echo "- **Branch:** ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
echo "- **Commit:** ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY