Skip to content

Commit 663523a

Browse files
authored
Merge pull request #1 from PandasWhoCode/copilot/create-initialize-github-job-action
Add composite action for GitHub job initialization with multi-language support
2 parents 90f719e + 509858e commit 663523a

3 files changed

Lines changed: 414 additions & 1 deletion

File tree

.github/workflows/test.yml

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