-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
150 lines (135 loc) · 4.36 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
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
name: Setup JavaScript/TypeScript Environment
branding:
icon: settings
color: blue
description: |
This action sets up the runtime, installs dependencies, and runs scripts for Node.js, Deno, or Bun.
inputs:
runtime:
description: 'The runtime to use (node, deno, or bun)'
required: false
default: node
version:
description: 'The version of the runtime'
required: false
default: latest
pm:
description: 'Package manager to use (npm, yarn, pnpm)'
required: false
scripts:
description: 'A comma-separated list of scripts to run in order (e.g., lint, build, test)'
required: false
cwd:
description: 'Current working directory for commands'
required: false
default: '.'
outputs:
runtime:
description: 'Runtime used'
value: ''
version:
description: 'Version of the runtime used'
value: ''
pm:
description: 'Detected package manager'
value: ''
pm_version:
description: 'Version of the package manager'
value: ''
pm_lockfile:
description: 'Detected lockfile'
value: ''
os:
description: 'The operating system used'
value: ''
os_name:
description: 'The name of the operating system'
value: ''
os_version:
description: 'The version of the operating system'
value: ''
os_arch:
description: 'The architecture of the operating system'
value: ''
runs:
using: 'composite'
steps:
- name: 🛠️ Prepare the environment
run: |
chmod +x "${{ github.action_path }}/scripts/prepare.sh"
bash "${{ github.action_path }}/scripts/prepare.sh"
shell: bash
- name: 🔍 Detect the execution environment
working-directory: ${{ inputs.cwd }}
run: |
chmod +x "${{ github.action_path }}/scripts/setup.sh"
bash "${{ github.action_path }}/scripts/setup.sh"
env:
runtime: ${{ inputs.runtime }}
pm: ${{ inputs.pm }}
cwd: ${{ inputs.cwd }}
GITHUB_ENV: $GITHUB_ENV
shell: bash
- name: 📋 Display detected values
run: |
echo "Runtime: ${{ env.runtime }}"
echo "Package Manager: ${{ env.pm }}"
echo "Version: ${{ env.pm_version }}"
echo "Lockfile: ${{ env.pm_lockfile }}"
echo "------------------------"
echo "Operating System: ${{ env.os }}"
echo "Name: ${{ env.os_name }}"
echo "Version: ${{ env.os_version }}"
echo "Architecture: ${{ env.os_arch }}"
shell: bash
- name: 📦 Setup PNPM
if: ${{ env.pm == 'pnpm' }}
uses: pnpm/action-setup@v4
with:
version: ${{ env.pm_version }}
package_json_file: "${{ inputs.cwd }}/package.json"
- name: 🐳 Set up Node.js
if: ${{ (inputs.runtime == 'node' || env.pm == 'npm' || env.pm == 'pnpm' || env.pm == 'yarn') && env.pm_lockfile }}
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.version }}
cache: ${{ env.pm }}
cache-dependency-path: ${{ env.pm_lockfile }}
- name: 🐳 Set up Node.js
if: ${{ inputs.runtime == 'node' || env.pm == 'npm' || env.pm == 'pnpm' || env.pm == 'yarn' }}
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.version }}
- name: 🦕 Set up Deno
if: ${{ inputs.runtime == 'deno' || env.pm == 'deno' }}
uses: denoland/setup-deno@v2
with:
deno-version: ${{ inputs.version }}
- name: 🦄 Set up Bun
if: ${{ inputs.runtime == 'bun' || env.pm == 'bun' }}
uses: oven-sh/setup-bun@v2
with:
bun-version: ${{ inputs.version }}
- name: 📥 Install dependencies
working-directory: ${{ inputs.cwd }}
run: |
chmod +x "${{ github.action_path }}/scripts/install.sh"
bash "${{ github.action_path }}/scripts/install.sh"
env:
pm: ${{ env.pm }}
shell: bash
- name: 🔨 Execute scripts
if: ${{ inputs.scripts }}
working-directory: ${{ inputs.cwd }}
run: |
chmod +x "${{ github.action_path }}/scripts/run.sh"
bash "${{ github.action_path }}/scripts/run.sh"
env:
scripts: ${{ inputs.scripts }}
pm: ${{ env.pm }}
shell: bash
- name: 🎉 Finish test workflow
run: |
echo "🎯 Setup completed for ${{ inputs.runtime }}@${{ inputs.version }}!"
echo "${{ env.pm }}@${{ env.pm_version }} was used as dependency manager 📦️"
shell: bash