Skip to content

Commit 68a2c71

Browse files
author
ansible-repo-updater[bot]
committed
chore: sync from template v2.0.0
1 parent b490737 commit 68a2c71

4 files changed

Lines changed: 121 additions & 92 deletions

File tree

.github/workflows/rebase.yaml

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

.github/workflows/release.yaml

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

.github/workflows/semantic.yaml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
---
2+
name: Semantic
3+
4+
"on":
5+
pull_request:
6+
branches:
7+
- main
8+
push:
9+
branches:
10+
- main
11+
- release
12+
13+
jobs:
14+
rebase:
15+
name: "Rebase"
16+
runs-on: ubuntu-latest
17+
# Runs when: push to main with commit message starting with "chore(release):"
18+
if: >-
19+
github.event_name == 'push' &&
20+
github.ref == 'refs/heads/main' &&
21+
startsWith(github.event.head_commit.message, 'chore(release):')
22+
concurrency:
23+
group: push-rebase-main
24+
cancel-in-progress: true
25+
permissions:
26+
pull-requests: write
27+
contents: write
28+
steps:
29+
- name: "Rebase all non-draft non-dependencies pull requests"
30+
uses: peter-evans/rebase@v4.0.0
31+
with:
32+
base: main
33+
exclude-drafts: true
34+
exclude-labels: dependencies
35+
36+
validate:
37+
name: "Validate"
38+
runs-on: ubuntu-latest
39+
# Runs when: pull_request targeting main
40+
if: github.event_name == 'pull_request'
41+
permissions:
42+
contents: read
43+
steps:
44+
- name: Checkout
45+
uses: actions/checkout@v6
46+
with:
47+
fetch-depth: 0
48+
49+
- name: Semantic release dry run
50+
run: |
51+
docker run --rm \
52+
--user 1001 \
53+
-v ${{ github.workspace }}:/workspace \
54+
-w /workspace \
55+
ghcr.io/disafronov/semantic-release:latest \
56+
--dry-run
57+
58+
release:
59+
name: "Release"
60+
runs-on: ubuntu-latest
61+
# Runs when: push to release OR push to main (excluding "chore(release):" commits)
62+
if: >-
63+
github.event_name == 'push' && (
64+
github.ref == 'refs/heads/release' ||
65+
(github.ref == 'refs/heads/main' && !startsWith(github.event.head_commit.message, 'chore(release):'))
66+
)
67+
permissions:
68+
contents: write
69+
pull-requests: write
70+
concurrency:
71+
group: semantic-release
72+
cancel-in-progress: false
73+
steps:
74+
- name: Checkout
75+
uses: actions/checkout@v6
76+
with:
77+
fetch-depth: 0
78+
token: ${{ secrets.SEMANTIC_RELEASE_TOKEN || secrets.GITHUB_TOKEN }}
79+
80+
- name: Semantic release
81+
run: |
82+
docker run --rm \
83+
--user 1001 \
84+
-v ${{ github.workspace }}:/workspace \
85+
-w /workspace \
86+
-e GITHUB_TOKEN=${{ secrets.SEMANTIC_RELEASE_TOKEN || secrets.GITHUB_TOKEN }} \
87+
-e CI=true \
88+
ghcr.io/disafronov/semantic-release:latest
89+
90+
- name: Sync release to main
91+
# Runs when: release job ran on release branch
92+
if: success() && github.ref == 'refs/heads/release'
93+
run: |
94+
git config user.name "Release Bot"
95+
git config user.email "noreply@github.com"
96+
97+
# Fetch latest state after semantic-release pushed commits
98+
# This ensures we get all commits that semantic-release created
99+
git fetch origin
100+
101+
# Check if main is already up to date with release
102+
if git diff --quiet origin/main origin/release; then
103+
echo "main is already up to date with release"
104+
exit 0
105+
fi
106+
107+
# Check if main is ancestor of release (can fast-forward)
108+
if git merge-base --is-ancestor origin/main origin/release; then
109+
echo "Fast-forwarding main to release"
110+
git checkout -B main origin/main
111+
git merge --ff-only origin/release
112+
git push origin main
113+
else
114+
echo "Rebasing main onto release (force-with-lease required)"
115+
git checkout -B main origin/main
116+
git rebase origin/release
117+
# Use --force-with-lease for safety: only push if remote hasn't changed
118+
git push --force-with-lease origin main
119+
fi
120+
env:
121+
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN || secrets.GITHUB_TOKEN }}

.github/workflows/validate.yaml

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

0 commit comments

Comments
 (0)