-
Notifications
You must be signed in to change notification settings - Fork 1
115 lines (99 loc) · 3.85 KB
/
Copy pathsolid-workflow.yml
File metadata and controls
115 lines (99 loc) · 3.85 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: Solid
on:
workflow_call:
inputs:
ENVIRONMENT:
required: true
type: string
secrets:
RTC_GITHUB_REGISTRY:
required: true
ENVIRONMENT_NAME:
required: true
SSH_DEPLOY_KEY:
required: true
DESTINATION_REPO:
required: true
DESTINATION_USER:
required: false
TARGET_BRANCH:
required: true
jobs:
solid-deploy:
runs-on: ubuntu-latest
environment: ${{ inputs.ENVIRONMENT }}
steps:
- uses: actions/checkout@v3
name: Checkout Site
- uses: actions/setup-node@v3
name: Setup Node
with:
node-version: 22
registry-url: "https://npm.pkg.github.com"
- name: Install Dependencies (Clean)
run: |
rm -rf node_modules
npm install
env:
NODE_AUTH_TOKEN: ${{ secrets.RTC_GITHUB_REGISTRY }}
# --------------------------------------------------------------------
# Extract version from package.json
# --------------------------------------------------------------------
- name: Extract package version
id: version
run: |
VERSION=$(node -p "require('./package.json').version")
echo "version=$VERSION" >> $GITHUB_OUTPUT
# --------------------------------------------------------------------
# Build Angular plugin with dynamic baseHref = /<version>/
# --------------------------------------------------------------------
- name: Build plugin with dynamic baseHref
run: |
VERSION=${{ steps.version.outputs.version }}
echo "Building plugin with baseHref '/$VERSION/'"
npx ng build plugin --base-href "/$VERSION/"
env:
NODE_AUTH_TOKEN: ${{ secrets.RTC_GITHUB_REGISTRY }}
# --------------------------------------------------------------------
# Prepare versioned output folder
# --------------------------------------------------------------------
- name: Prepare versioned output folder
run: |
VERSION=${{ steps.version.outputs.version }}
mkdir -p deploy/$VERSION
cp -R dist/plugin/browser/* deploy/$VERSION/
# --------------------------------------------------------------------
# Release stamp (optional)
# --------------------------------------------------------------------
- name: Generate Release Stamp
id: release
run: echo "stamp=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT
# --------------------------------------------------------------------
# Push ONLY the versioned folder and DO NOT overwrite remote repo content
# --------------------------------------------------------------------
- name: Push version folder safely
run: |
# 1. Write SSH key to file
mkdir -p ~/.ssh
echo "${{ secrets.SSH_DEPLOY_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
# 2. Configure SSH
cat >> ~/.ssh/config <<EOF
Host github.com
IdentityFile ~/.ssh/id_rsa
StrictHostKeyChecking no
EOF
VERSION="${{ steps.version.outputs.version }}"
echo "Cloning target repository…"
git clone git@github.com:${{ secrets.DESTINATION_USER || 'rollthecloudinc' }}/${{ secrets.DESTINATION_REPO }}.git target-repo
cd target-repo
git checkout ${{ secrets.TARGET_BRANCH }}
echo "Copying new version folder…"
mkdir -p "$VERSION"
cp -R ../deploy/$VERSION/* "$VERSION/"
git add "$VERSION"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git commit -m "Add version $VERSION" || echo "No changes to commit"
echo "Pushing…"
git push origin ${{ secrets.TARGET_BRANCH }}