-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (82 loc) · 2.94 KB
/
deploy.yml
File metadata and controls
95 lines (82 loc) · 2.94 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
94
95
name: Deploy to TelemetryX
on:
push:
branches: [main]
tags:
- 'v*'
workflow_dispatch:
inputs:
environment:
description: 'Environment to deploy to'
required: true
default: 'staging'
type: choice
options:
- staging
- production
applications:
description: 'Applications to deploy (comma-separated, or "all")'
required: true
default: 'all'
env:
TELEMETRYX_API_URL: ${{ secrets.TELEMETRYX_API_URL }}
jobs:
build-and-deploy:
name: Build and Deploy
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment || 'staging' }}
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm run test
- name: Build applications
run: npm run build
env:
NODE_ENV: production
TELEMETRYX_SDK_TOKEN: ${{ secrets.TELEMETRYX_SDK_TOKEN }}
- name: Determine applications to deploy
id: apps
run: |
if [ "${{ github.event.inputs.applications }}" == "all" ] || [ -z "${{ github.event.inputs.applications }}" ]; then
echo "apps=$(ls -d applications/* | xargs -n1 basename | tr '\n' ' ')" >> $GITHUB_OUTPUT
else
echo "apps=${{ github.event.inputs.applications }}" >> $GITHUB_OUTPUT
fi
- name: Deploy to TelemetryX
uses: telemetrytv/deploy-action@v1
with:
api-key: ${{ secrets.TELEMETRYX_DEPLOY_KEY }}
environment: ${{ github.event.inputs.environment || 'staging' }}
applications: ${{ steps.apps.outputs.apps }}
path: applications
- name: Create deployment record
if: success()
run: |
echo "Deployment successful!"
echo "Environment: ${{ github.event.inputs.environment || 'staging' }}"
echo "Applications: ${{ steps.apps.outputs.apps }}"
echo "Commit: ${{ github.sha }}"
echo "Timestamp: $(date -u +"%Y-%m-%dT%H:%M:%SZ")"
- name: Notify deployment status
if: always()
uses: actions/github-script@v7
with:
script: |
const status = '${{ job.status }}' === 'success' ? '✅' : '❌';
const environment = '${{ github.event.inputs.environment || 'staging' }}';
const apps = '${{ steps.apps.outputs.apps }}';
await github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.sha,
state: '${{ job.status }}' === 'success' ? 'success' : 'failure',
description: `Deployment to ${environment} ${status}`,
context: 'TelemetryX Deploy'
});