Skip to content

Commit 891afc5

Browse files
committed
Adding some documentation
1 parent 0083eeb commit 891afc5

2 files changed

Lines changed: 132 additions & 0 deletions

File tree

.github/workflows/README-deploy.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Deploy Workflow
2+
3+
A reusable GitHub Actions workflow for building and deploying Spring Cloud projects. It uses centralized configuration to determine which branches and JDK versions to build, then runs Maven with the appropriate profiles for each matrix combination.
4+
5+
## Description
6+
7+
The workflow is designed to be called from Spring Cloud project repositories via `workflow_call`. It:
8+
9+
- **Determines the build matrix** using the [determine-matrix](../actions/determine-matrix/README.md) action and [`config/projects.json`](../../config/projects.json), supporting both OSS and commercial repository variants
10+
- **Builds each branch × JDK combination** in parallel with a matrix strategy
11+
- **Deploys artifacts and docs** only for designated JDK versions (e.g., JDK 8 when present, otherwise JDK 17), while other JDK versions run `install` only
12+
- **Supports custom build commands** so callers can override the default Maven behavior
13+
14+
The workflow configures Maven settings for Artifactory (OSS and optional commercial), checks out the correct branch, sets up the JDK, and runs either the default Maven deploy/install or a custom command.
15+
16+
## Requirements
17+
18+
- The calling repository must use Maven with a `mvnw` wrapper
19+
- Required secrets must be configured in the calling repository (or passed from the caller)
20+
21+
## Inputs
22+
23+
| Input | Description | Required | Type |
24+
|-------|-------------|----------|------|
25+
| `branches` | Branch(es) to build — single branch or comma-separated list (e.g. `main,3.3.x,3.2.x`). Empty uses ref or scheduled config. | No | string |
26+
| `custom_build_command` | Custom run command for the build step (overrides default Maven command). Supports multi-line. | No | string |
27+
| `runs_on` | Runner to use for the build job. | No | string (default: `ubuntu-latest`) |
28+
29+
## Secrets
30+
31+
| Secret | Description | Required |
32+
|--------|-------------|----------|
33+
| `ARTIFACTORY_USERNAME` | Username for OSS Artifactory (repo.spring.io) | Yes |
34+
| `ARTIFACTORY_PASSWORD` | Password for OSS Artifactory | Yes |
35+
| `COMMERCIAL_ARTIFACTORY_USERNAME` | Username for commercial Artifactory | No (required for *-commercial repos) |
36+
| `COMMERCIAL_ARTIFACTORY_PASSWORD` | Password for commercial Artifactory | No (required for *-commercial repos) |
37+
| `DOCKERHUB_USERNAME` | Docker Hub username | Yes |
38+
| `DOCKERHUB_TOKEN` | Docker Hub token | Yes |
39+
40+
## How It Works
41+
42+
1. **Setup job**: Runs the [determine-matrix](../actions/determine-matrix/README.md) action to produce a matrix of `branch`, `java-version`, and `has-jdk8` from [`config/projects.json`](../../config/projects.json).
43+
2. **Build job** (matrix): For each matrix entry:
44+
- Checkout the branch, set up the JDK, configure Maven and Docker Hub
45+
- Decide whether this combination should deploy (and use the docs profile) based on `has-jdk8` and `java-version`
46+
- Run either:
47+
- **Build**: `./mvnw clean install -Pspring -B -U` when not deploying
48+
- **Build and deploy**: `./mvnw clean deploy -Pdocs,deploy,spring -B -U` for the designated deploy JDK
49+
- **Custom build command**: The caller-provided command, if set
50+
51+
Deploy and docs are enabled for one JDK per branch (JDK 8 if the branch has JDK 8, otherwise JDK 17).
52+
53+
## Usage
54+
55+
### Basic usage from a Spring Cloud repo
56+
57+
In your project’s `.github/workflows/deploy.yml`:
58+
59+
```yaml
60+
jobs:
61+
deploy:
62+
uses: spring-cloud/spring-cloud-github-actions/.github/workflows/deploy.yml@main
63+
with:
64+
branches: ${{ inputs.branches }}
65+
runs_on: ${{ inputs.runs_on }}
66+
secrets:
67+
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
68+
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
69+
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
70+
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
71+
```
72+
73+
For commercial projects, also pass `COMMERCIAL_ARTIFACTORY_USERNAME` and `COMMERCIAL_ARTIFACTORY_PASSWORD`.
74+
75+
### Example caller workflow
76+
77+
A full example with `push`, `schedule`, and `workflow_dispatch` (including optional `branches` and `runs_on`) is in [examples/deploy.yml](../../examples/deploy.yml). Copy and adapt that file into your project’s `.github/workflows/deploy.yml`.
78+
79+
### Custom build command
80+
81+
To override the default Maven command:
82+
83+
```yaml
84+
with:
85+
branches: ${{ inputs.branches }}
86+
custom_build_command: |
87+
./mvnw clean install -B
88+
./mvnw verify -B
89+
```
90+
91+
## Configuration
92+
93+
Branch and JDK version behavior is driven by [config/projects.json](../../config/projects.json) and the [determine-matrix](../actions/determine-matrix/README.md) action. The workflow does not define branches or JDK versions itself; it only consumes the matrix produced by that action.
94+
95+
## See also
96+
97+
- [Determine Build Matrix action](../actions/determine-matrix/README.md) — builds the matrix from `config/projects.json`
98+
- [Example caller workflow](../../examples/deploy.yml) — ready-to-adapt workflow for Spring Cloud projects

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Spring Cloud GitHub Actions
2+
3+
Shared GitHub Actions workflows and composite actions for Spring Cloud projects. This repository provides reusable automation for building, testing, and deploying Spring Cloud repositories with consistent branch and JDK version handling.
4+
5+
## Contents
6+
7+
- **[Workflows](.github/workflows/)** — Reusable workflows callable from other repositories
8+
- **[Actions](.github/actions/)** — Composite actions used by those workflows (and optionally by callers)
9+
- **[Config](config/)** — Centralized configuration (e.g. branches and JDK versions per project)
10+
- **[Examples](examples/)** — Example caller workflows you can copy into your project
11+
12+
## Workflows
13+
14+
| Workflow | Description | Documentation |
15+
|----------|-------------|----------------|
16+
| [deploy.yml](.github/workflows/deploy.yml) | Build and deploy Spring Cloud projects with matrix builds (branch × JDK). Uses centralized config to decide what to build and deploy. | [Deploy workflow README](.github/workflows/README-deploy.md) |
17+
18+
## Actions
19+
20+
| Action | Description | Documentation |
21+
|--------|-------------|---------------|
22+
| [determine-matrix](.github/actions/determine-matrix/) | Reads [config/projects.json](config/projects.json) and produces a build matrix (branches × JDK versions) for the current repo and event. Supports OSS/commercial, scheduled vs single-branch, and comma-separated branch overrides. | [Determine Matrix README](.github/actions/determine-matrix/README.md) |
23+
24+
## Configuration
25+
26+
- **[config/projects.json](config/projects.json)** — Defines, per project, which branches to build (e.g. for scheduled runs) and which JDK versions to use per branch. Includes separate `oss` and `commercial` sections and a `defaults` fallback. The [determine-matrix](.github/actions/determine-matrix/README.md) action reads this file to build the matrix used by the [deploy](.github/workflows/README-deploy.md) workflow.
27+
28+
## Quick start
29+
30+
1. In your Spring Cloud project, add a workflow that calls the deploy workflow (see [examples/deploy.yml](examples/deploy.yml)).
31+
2. Configure the required secrets in your repository (`ARTIFACTORY_*`, `DOCKERHUB_*`; add `COMMERCIAL_*` for commercial repos).
32+
3. Trigger via push, schedule, or `workflow_dispatch`. The deploy workflow will use this repo’s config and actions to decide what to build and deploy.
33+
34+
For full details on inputs, secrets, and behavior, see the [Deploy workflow README](.github/workflows/README-deploy.md) and the [Determine Matrix action README](.github/actions/determine-matrix/README.md).

0 commit comments

Comments
 (0)