Skip to content

Commit 8cc6532

Browse files
Copilotrbarker-dev
andcommitted
Create initialize-github-job composite action with multi-language support
Co-authored-by: rbarker-dev <164891078+rbarker-dev@users.noreply.github.com>
1 parent f6d3225 commit 8cc6532

3 files changed

Lines changed: 411 additions & 1 deletion

File tree

.github/workflows/test.yml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: Test Action
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
test-basic-checkout:
12+
name: Test Basic Checkout
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Initialize job
16+
uses: ./
17+
18+
- name: Verify checkout
19+
run: |
20+
echo "Current directory: $(pwd)"
21+
echo "Files in repo:"
22+
ls -la
23+
24+
test-node:
25+
name: Test Node.js Setup
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Initialize job with Node.js
29+
uses: ./
30+
with:
31+
setup-node: 'true'
32+
node-version: '20'
33+
node-cache: 'npm'
34+
35+
- name: Verify Node.js
36+
run: |
37+
node --version
38+
npm --version
39+
40+
test-python:
41+
name: Test Python Setup
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Initialize job with Python
45+
uses: ./
46+
with:
47+
setup-python: 'true'
48+
python-version: '3.11'
49+
50+
- name: Verify Python
51+
run: |
52+
python --version
53+
pip --version
54+
55+
test-java:
56+
name: Test Java Setup
57+
runs-on: ubuntu-latest
58+
steps:
59+
- name: Initialize job with Java
60+
uses: ./
61+
with:
62+
setup-java: 'true'
63+
java-version: '17'
64+
java-distribution: 'temurin'
65+
66+
- name: Verify Java
67+
run: |
68+
java -version
69+
javac -version
70+
71+
test-go:
72+
name: Test Go Setup
73+
runs-on: ubuntu-latest
74+
steps:
75+
- name: Initialize job with Go
76+
uses: ./
77+
with:
78+
setup-go: 'true'
79+
go-version: '1.21'
80+
81+
- name: Verify Go
82+
run: |
83+
go version
84+
85+
test-multi-language:
86+
name: Test Multi-Language Setup
87+
runs-on: ubuntu-latest
88+
steps:
89+
- name: Initialize job with multiple languages
90+
uses: ./
91+
with:
92+
setup-node: 'true'
93+
node-version: '20'
94+
setup-python: 'true'
95+
python-version: '3.11'
96+
97+
- name: Verify all languages
98+
run: |
99+
echo "Node version: $(node --version)"
100+
echo "npm version: $(npm --version)"
101+
echo "Python version: $(python --version)"
102+
echo "pip version: $(pip --version)"
103+
104+
test-no-checkout:
105+
name: Test Without Checkout
106+
runs-on: ubuntu-latest
107+
steps:
108+
- name: Manual checkout
109+
uses: actions/checkout@v4
110+
111+
- name: Initialize job without checkout
112+
uses: ./
113+
with:
114+
checkout: 'false'
115+
setup-node: 'true'
116+
node-version: '20'
117+
118+
- name: Verify setup
119+
run: |
120+
node --version
121+
ls -la

README.md

Lines changed: 178 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,179 @@
11
# initialize-github-job
2-
Common steps for initializing a job for GitHub actions
2+
3+
Common steps for initializing a job for GitHub actions. This composite action provides a flexible way to set up your GitHub Actions workflow with repository checkout and various programming language runtimes.
4+
5+
## Features
6+
7+
- 🔄 Repository checkout with customizable options
8+
- 🟢 Node.js setup with version management and caching
9+
- 🐍 Python setup with version management and caching
10+
- ☕ Java setup with multiple distributions
11+
- 🔵 Go setup with module caching
12+
- ⚡ Optimized with dependency caching support
13+
14+
## Usage
15+
16+
### Basic Example - Checkout Only
17+
18+
```yaml
19+
- name: Initialize job
20+
uses: PandasWhoCode/initialize-github-job@v1
21+
```
22+
23+
### Node.js Project
24+
25+
```yaml
26+
- name: Initialize Node.js job
27+
uses: PandasWhoCode/initialize-github-job@v1
28+
with:
29+
setup-node: 'true'
30+
node-version: '20'
31+
node-cache: 'npm'
32+
```
33+
34+
### Python Project
35+
36+
```yaml
37+
- name: Initialize Python job
38+
uses: PandasWhoCode/initialize-github-job@v1
39+
with:
40+
setup-python: 'true'
41+
python-version: '3.11'
42+
python-cache: 'pip'
43+
```
44+
45+
### Java Project
46+
47+
```yaml
48+
- name: Initialize Java job
49+
uses: PandasWhoCode/initialize-github-job@v1
50+
with:
51+
setup-java: 'true'
52+
java-version: '17'
53+
java-distribution: 'temurin'
54+
```
55+
56+
### Go Project
57+
58+
```yaml
59+
- name: Initialize Go job
60+
uses: PandasWhoCode/initialize-github-job@v1
61+
with:
62+
setup-go: 'true'
63+
go-version: '1.21'
64+
```
65+
66+
### Multi-Language Project
67+
68+
```yaml
69+
- name: Initialize multi-language job
70+
uses: PandasWhoCode/initialize-github-job@v1
71+
with:
72+
setup-node: 'true'
73+
node-version: '20'
74+
node-cache: 'npm'
75+
setup-python: 'true'
76+
python-version: '3.11'
77+
python-cache: 'pip'
78+
```
79+
80+
### Skip Checkout
81+
82+
```yaml
83+
- name: Initialize without checkout
84+
uses: PandasWhoCode/initialize-github-job@v1
85+
with:
86+
checkout: 'false'
87+
setup-node: 'true'
88+
node-version: '20'
89+
```
90+
91+
### Custom Checkout Options
92+
93+
```yaml
94+
- name: Initialize with custom checkout
95+
uses: PandasWhoCode/initialize-github-job@v1
96+
with:
97+
checkout-ref: 'develop'
98+
checkout-token: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
99+
setup-node: 'true'
100+
```
101+
102+
## Inputs
103+
104+
### Checkout Options
105+
106+
| Input | Description | Required | Default |
107+
|-------|-------------|----------|---------|
108+
| `checkout` | Whether to checkout the repository | No | `true` |
109+
| `checkout-ref` | The branch, tag or SHA to checkout | No | `''` |
110+
| `checkout-token` | Personal access token (PAT) used to fetch the repository | No | `${{ github.token }}` |
111+
112+
### Node.js Options
113+
114+
| Input | Description | Required | Default |
115+
|-------|-------------|----------|---------|
116+
| `setup-node` | Whether to setup Node.js | No | `false` |
117+
| `node-version` | Node.js version to use | No | `20` |
118+
| `node-version-file` | File containing the Node.js version (e.g., `.nvmrc`, `.node-version`) | No | `''` |
119+
| `node-cache` | Package manager for caching (`npm`, `yarn`, `pnpm`) | No | `''` |
120+
121+
### Python Options
122+
123+
| Input | Description | Required | Default |
124+
|-------|-------------|----------|---------|
125+
| `setup-python` | Whether to setup Python | No | `false` |
126+
| `python-version` | Python version to use | No | `3.x` |
127+
| `python-cache` | Package manager for caching (`pip`, `pipenv`, `poetry`) | No | `''` |
128+
129+
### Java Options
130+
131+
| Input | Description | Required | Default |
132+
|-------|-------------|----------|---------|
133+
| `setup-java` | Whether to setup Java | No | `false` |
134+
| `java-version` | Java version to use | No | `17` |
135+
| `java-distribution` | Java distribution (`temurin`, `zulu`, `adopt`, etc.) | No | `temurin` |
136+
137+
### Go Options
138+
139+
| Input | Description | Required | Default |
140+
|-------|-------------|----------|---------|
141+
| `setup-go` | Whether to setup Go | No | `false` |
142+
| `go-version` | Go version to use | No | `stable` |
143+
| `go-cache` | Whether to cache Go modules | No | `true` |
144+
145+
## Complete Workflow Example
146+
147+
```yaml
148+
name: CI
149+
150+
on:
151+
push:
152+
branches: [ main ]
153+
pull_request:
154+
branches: [ main ]
155+
156+
jobs:
157+
build:
158+
runs-on: ubuntu-latest
159+
steps:
160+
- name: Initialize job
161+
uses: PandasWhoCode/initialize-github-job@v1
162+
with:
163+
setup-node: 'true'
164+
node-version: '20'
165+
node-cache: 'npm'
166+
167+
- name: Install dependencies
168+
run: npm ci
169+
170+
- name: Run tests
171+
run: npm test
172+
173+
- name: Build
174+
run: npm run build
175+
```
176+
177+
## License
178+
179+
This project is licensed under the terms specified in the LICENSE file.

0 commit comments

Comments
 (0)