Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/branch-promotion-prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Automated Branch Promotion PRs

on:
workflow_call:
inputs:
source-branch:
description: 'Source branch to promote from'
type: string
default: 'develop'
target-branches:
description: 'JSON array of target branches to promote to'
type: string
required: true
pr-title-template:
description: 'Template for PR title (use {0} placeholder for branch)'
type: string
default: 'Update {0} env'
pr-body-template:
description: 'Template for PR body (use {0} for branch and {1} for source placeholders)'
type: string
default: 'This PR updates the {0} environment with the latest changes from the {1} branch.'
draft-pr:
description: 'Create PRs as drafts'
type: boolean
default: true
reviewers:
description: 'A comma or newline-separated list of reviewers (GitHub usernames) to request'
type: string
required: false
team-reviewers:
description: 'A comma or newline-separated list of GitHub teams to request as reviewers'
type: string
required: false
secrets:
gh-token:
description: 'GitHub token for creating PRs'
required: true

permissions:
contents: read

jobs:
promotion:
runs-on: ubuntu-latest
strategy:
matrix:
branch: ${{ fromJson(inputs.target-branches) }}
steps:
- name: Checkout
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
ref: ${{ matrix.branch }}

- name: Reset promotion branch
run: |
git fetch origin ${{ inputs.source-branch }}
git reset --hard origin/${{ inputs.source-branch }}

- name: Create Pull Request
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
with:
branch: ${{ inputs.source-branch }}
title: ${{ format(inputs.pr-title-template, matrix.branch) }}
draft: ${{ inputs.draft-pr }}
body: ${{ format(inputs.pr-body-template, matrix.branch, inputs.source-branch) }}
reviewers: ${{ inputs.reviewers }}
team-reviewers: ${{ inputs.team-reviewers }}
token: ${{ secrets.gh-token }}
35 changes: 33 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ Here follows the list of GitHub Actions topics available in the current document
- [validate-maven-versions](#validate-maven-versions)
- [veracode](#veracode)
- [Reusable workflows provided by us](#reusable-workflows-provided-by-us)
- [helm-publish-new-package-version.yml](#helm-publish-new-package-versionyml)
- [branch-promotion-prs](#branch-promotion-prs)
- [helm-publish-new-package-version](#helm-publish-new-package-version)
- [terraform](#terraform)
- [Cookbook](#cookbook)
- [Conditional job/step depending on PR labels](#conditional-jobstep-depending-on-pr-labels)
Expand Down Expand Up @@ -2163,7 +2164,37 @@ This way, the agent-based scan results will be added in the latest promoted scan

## Reusable workflows provided by us

### helm-publish-new-package-version.yml
### branch-promotion-prs

Automates the creation of pull requests to promote changes from a source branch to multiple target branches. This workflow is useful for promoting changes across different environments (e.g., from develop to staging and production branches).

```yaml
name: Promote to Environment Branches

on:
push:
branches:
- 'develop' # Source branch to monitor for changes

permissions:
contents: write # Required to create pull requests

jobs:
promote:
uses: Alfresco/alfresco-build-tools/.github/workflows/branch-promotion-prs.yml@ref
with:
source-branch: 'develop' # default branch to promote from
target-branches: '["staging", "production"]' # JSON array of branches to promote to
pr-title-template: 'Promote to {0} environment' # optional
pr-body-template: 'This PR promotes the latest changes from {1} to the {0} environment.' # optional
draft-pr: false
reviewers: 'user1,user2,user3' # optional - comma or newline-separated list of GitHub usernames
team-reviewers: 'team1,team2' # optional - comma or newline-separated list of GitHub teams
secrets:
gh-token: ${{ secrets.BOT_GITHUB_TOKEN }}
```

### helm-publish-new-package-version

Calculates the new alpha version, creates new git tag and publishes the new package to the helm chart repository

Expand Down
18 changes: 6 additions & 12 deletions docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,17 +173,11 @@ jobs:
secrets: inherit
```

## Environment badges
## Branch promotion workflow

At the top of the README file, you should list a badge for every configured environment, to ease raising PRs to keep them up to date. You can use the following Markdown snippet to add a badge for each environment:
For Terraform projects with multiple environment branches, you can use the
branch promotion workflow to automate the creation of pull requests when
promoting changes across environments.

```markdown
[![update ENV-NAME env](https://img.shields.io/badge/⚠️-update%20ENV--NAME%20env-blue)](https://github.com/Alfresco/REPO-NAME/compare/ENV-NAME...develop?expand=1&title=Update%20ENV-NAME%20env)
```

Replace `REPO-NAME` with the name of the GitHub repository and `ENV-NAME` with
the name of the environment (e.g., `development`, `staging`, `production`) which
also correspond to the branch name.

Please note that `img.shields.io` badge also requires escaping single dash to
double dash to work properly.
See [main documentation](README.md#branch-promotion-prs) for usage
documentation.
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v9.0.1
v9.1.0
Loading