Skip to content

Commit f9be380

Browse files
authored
Merge pull request #94 from mvallim/release/1.0.7
Auto-created pull request into `master` from `release/1.0.7`
2 parents 715ca8e + 9d05f4e commit f9be380

File tree

6 files changed

+185
-85
lines changed

6 files changed

+185
-85
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Build, Gates and Pull Request
2+
3+
on:
4+
pull_request_target:
5+
branches:
6+
- develop
7+
types:
8+
- closed
9+
- synchronize
10+
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
15+
jobs:
16+
variables:
17+
if: ${{ github.event.pull_request.merged == true }}
18+
runs-on: ubuntu-latest
19+
outputs:
20+
version: ${{ steps.environment.outputs.version }}
21+
target-branch: ${{ steps.environment.outputs.target-branch }}
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
26+
- name: Set up JDK
27+
uses: actions/setup-java@v4
28+
with:
29+
java-version: 17
30+
distribution: "corretto"
31+
cache: "maven"
32+
33+
- id: environment
34+
name: Set output environment passed to the reusable workflow
35+
run: |
36+
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout | cut -d '-' -f 1)
37+
echo "version=$VERSION" >> $GITHUB_OUTPUT
38+
echo "target-branch=release/$VERSION" >> $GITHUB_OUTPUT
39+
40+
ci:
41+
needs: variables
42+
uses: ./.github/workflows/ci-maven.yml
43+
secrets: inherit
44+
45+
gates:
46+
needs: ci
47+
if: success()
48+
uses: ./.github/workflows/ci-gates.yml
49+
secrets: inherit
50+
51+
pull-request:
52+
needs: [gates, variables]
53+
uses: ./.github/workflows/ci-pull-request.yml
54+
secrets: inherit
55+
with:
56+
type: Snapshot
57+
labels: automatic,snapshot
58+
source-branch: master
59+
target-branch: ${{ needs.variables.outputs.target-branch }}

.github/workflows/cd-release.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Build and Publish Release
2+
3+
on:
4+
pull_request_target:
5+
branches:
6+
- master
7+
types:
8+
- closed
9+
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
14+
jobs:
15+
ci:
16+
if: ${{ github.event.pull_request.merged == true }}
17+
uses: ./.github/workflows/ci-maven.yml
18+
secrets: inherit
19+
20+
# release:
21+
# needs: ci
22+
# uses: ./.github/workflows/cd-deploy.yml
23+
# secrets: inherit
24+
# with:
25+
# environment: release

.github/workflows/cd-snapshot.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Build, Publish Snapshot and Pull Request
2+
3+
on:
4+
pull_request_target:
5+
branches:
6+
- release/**
7+
types:
8+
- closed
9+
- synchronize
10+
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
15+
jobs:
16+
ci:
17+
if: ${{ github.event.pull_request.merged == true }}
18+
uses: ./.github/workflows/ci-maven.yml
19+
secrets: inherit
20+
21+
snapshot:
22+
needs: ci
23+
uses: ./.github/workflows/cd-deploy.yml
24+
secrets: inherit
25+
with:
26+
environment: snapshot
27+
28+
pull-request:
29+
needs: snapshot
30+
uses: ./.github/workflows/ci-pull-request.yml
31+
secrets: inherit
32+
with:
33+
type: Release
34+
labels: automatic,release
35+
source-branch: master
36+
target-branch: master

.github/workflows/cd.yml

Lines changed: 0 additions & 64 deletions
This file was deleted.

.github/workflows/ci-pull-request.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ name: Create Pull Request
33
on:
44
workflow_call:
55
inputs:
6+
source-branch:
7+
description: Source branch
8+
type: string
9+
required: true
610
target-branch:
711
description: Target branch
812
type: string
@@ -23,9 +27,39 @@ jobs:
2327
- name: Checkout repository
2428
uses: actions/checkout@v4
2529

30+
- name: Create branch
31+
run: |
32+
REPO="${{ github.repository }}"
33+
BRANCH="${{ inputs.target-branch }}"
34+
BASE="${{ inputs.source-branch }}"
35+
36+
echo "Checking if branch '$BRANCH' exists in repository '$REPO'..."
37+
38+
if gh api "repos/$REPO/branches/$BRANCH" --silent >/dev/null 2>&1; then
39+
echo "Branch '$BRANCH' already exists."
40+
else
41+
echo "Branch '$BRANCH' does not exist. It will be created from '$BASE'."
42+
43+
BASE_SHA=$(gh api "repos/$REPO/git/ref/heads/$BASE" --jq .object.sha)
44+
45+
if [ -z "$BASE_SHA" ]; then
46+
echo "Error: Could not retrieve the SHA of base branch '$BASE'"
47+
exit 1
48+
fi
49+
50+
gh api --method POST "repos/$REPO/git/refs" \
51+
-f ref="refs/heads/$BRANCH" \
52+
-f sha="$BASE_SHA"
53+
54+
echo "Branch '$BRANCH' successfully created!"
55+
fi
56+
env:
57+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
2659
- name: Create Pull Request (${{ inputs.type }})
2760
uses: peter-evans/create-pull-request@v7
2861
with:
62+
title: Auto-created pull request into `${{ inputs.target-branch }}` from `${{ github.ref_name }}`
2963
token: ${{ secrets.GITHUB_TOKEN }}
3064
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
3165
author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>

.github/workflows/ci.yml

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,51 +5,61 @@ on:
55
branches:
66
- feature/**
77
- fix/**
8-
paths-ignore:
9-
- "**/README.md"
10-
- "**/CONTRIBUTING.md"
11-
- "**/CONTRIBUTORS.txt"
12-
- "**/LICENSE"
138

149
env:
1510
TYPE: ${{ startsWith(github.ref_name, 'feature') && 'Feature' || 'Fix'}}
1611
LABELS: ${{ startsWith(github.ref_name, 'feature') && 'automatic,feature' || 'automatic,fix' }}
17-
TARGET_BRANCH: develop
1812

1913
permissions:
14+
contents: write
2015
pull-requests: write
2116

2217
jobs:
23-
set-outputs:
18+
variables:
2419
runs-on: ubuntu-latest
2520
outputs:
2621
type: ${{ steps.environment.outputs.type }}
2722
labels: ${{ steps.environment.outputs.labels }}
2823
target-branch: ${{ steps.environment.outputs.target-branch }}
2924
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
28+
- name: Set up JDK
29+
uses: actions/setup-java@v4
30+
with:
31+
java-version: 17
32+
distribution: "corretto"
33+
cache: "maven"
34+
3035
- id: environment
3136
name: Set output environment passed to the reusable workflow
3237
run: |
38+
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
39+
echo "version=$VERSION" >> $GITHUB_OUTPUT
3340
echo "type=$TYPE" >> $GITHUB_OUTPUT
3441
echo "labels=$LABELS" >> $GITHUB_OUTPUT
35-
echo "target-branch=$TARGET_BRANCH" >> $GITHUB_OUTPUT
42+
echo "target-branch=release/$VERSION" >> $GITHUB_OUTPUT
3643
37-
ci:
38-
uses: ./.github/workflows/ci-maven.yml
39-
secrets: inherit
44+
# ci:
45+
# needs: variables
46+
# uses: ./.github/workflows/ci-maven.yml
47+
# secrets: inherit
4048

41-
gates:
42-
needs: ci
43-
if: success()
44-
uses: ./.github/workflows/ci-gates.yml
45-
secrets: inherit
46-
49+
# gates:
50+
# needs: ci
51+
# if: success()
52+
# uses: ./.github/workflows/ci-gates.yml
53+
# secrets: inherit
54+
4755
pull-request:
48-
needs: [gates, set-outputs]
56+
# needs: [gates, variables]
57+
needs: variables
4958
if: success()
5059
uses: ./.github/workflows/ci-pull-request.yml
5160
secrets: inherit
5261
with:
53-
type: ${{ needs.set-outputs.outputs.type }}
54-
labels: ${{ needs.set-outputs.outputs.labels }}
55-
target-branch: ${{ needs.set-outputs.outputs.target-branch }}
62+
type: ${{ needs.variables.outputs.type }}
63+
labels: ${{ needs.variables.outputs.labels }}
64+
source-branch: ${{ github.ref_name }}
65+
target-branch: develop

0 commit comments

Comments
 (0)