Skip to content

Commit 82d30a4

Browse files
committed
Updated docs with information about triggers
1 parent a6d5098 commit 82d30a4

3 files changed

Lines changed: 45 additions & 2 deletions

File tree

.github/workflows/README-deploy.md

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Deploy and docs are enabled for one JDK per branch (JDK 8 if the branch has JDK
5454

5555
### Basic usage from a Spring Cloud repo
5656

57-
In your project’s `.github/workflows/deploy.yml`:
57+
In your project’s `.github/workflows/ci.yml`:
5858

5959
```yaml
6060
jobs:
@@ -72,6 +72,49 @@ jobs:
7272
7373
For commercial projects, also pass `COMMERCIAL_ARTIFACTORY_USERNAME` and `COMMERCIAL_ARTIFACTORY_PASSWORD`.
7474

75+
#### Triggering The Workflow
76+
77+
You can trigger the workflow from a variety of events. Most repos will want to trigger the workflow on pushes, a schedule, and a manual trigger.
78+
79+
```yaml
80+
on:
81+
push:
82+
branches:
83+
- main
84+
# other supported branched
85+
- 4.3.x
86+
- 4.2.x
87+
88+
# Scheduled builds run daily at midnight UTC
89+
schedule:
90+
- cron: '0 0 * * *'
91+
92+
# Manual trigger with optional branch override
93+
workflow_dispatch:
94+
inputs:
95+
branches:
96+
description: "Which branch should be built (can be a comma-separated list of branches)"
97+
required: true
98+
default: 'main'
99+
type: string
100+
```
101+
102+
There are a few things to note about how the schedule and push triggers work on GitHub.
103+
104+
##### Scheduled Triggers
105+
106+
**Scheduled triggers only get triggered from the repo's default branch.**
107+
This means that if `main` is the default branch in your repo and you have the configuration above setup in your workflow, that there will not be any scheduled execution on the 4.3.x. and 4.2.x branches. The `deploy.yaml` in this repo takes that into account. When your workflow is triggered to run via a schedule event `deploy.yaml` will setup the matrix to build all supported branches configured in the projects.json. When you look at the workflow in the GitHub Actions UI you will see something that looks like this for scheduled executions.
108+
109+
![scheduled_triggers.png](../../docs/images/scheduled_triggers.png)
110+
111+
Notice the workflow was triggered via a scheduled event, ran on the `main`
112+
branch (which is the default branch in this repo) but it checked out and built all supported branches for this repo (determined via `projects.json`).
113+
114+
##### Push Triggers
115+
116+
Given that scheduled triggers only execute on the default branch and we can build all the other branches from the default branch it might not seem necessary to have a workflow on the other supported branches in the repo. Unfortunately for push events the workflow needs to be present on the branch the push event occurred in order for it to execute. **If you want to build and deploy your snapshots on push events to branches other than the default branch your workflow also needs to be in the `.github/workflows` folder on those branches.**
117+
75118
### Example caller workflow
76119

77120
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`.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ Shared GitHub Actions workflows and composite actions for Spring Cloud projects.
2929

3030
1. In your Spring Cloud project, add a workflow that calls the deploy workflow (see [examples/deploy.yml](examples/deploy.yml)).
3131
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.
32+
3. Trigger via push, schedule, and/or `workflow_dispatch`. The deploy workflow will use this repo’s config and actions to decide what to build and deploy.
3333

3434
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).

docs/images/scheduled_triggers.png

81 KB
Loading

0 commit comments

Comments
 (0)