|
1 | 1 | # 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