-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (98 loc) · 3.74 KB
/
Copy pathrelease.yml
File metadata and controls
114 lines (98 loc) · 3.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: Create release
on:
push:
branches:
- main
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
environment: Netlogix Release Bot
steps:
- name: Checkout
uses: actions/checkout@v7
with:
persist-credentials: false
- name: Create GitHub App token
uses: actions/create-github-app-token@v3
id: release-bot-app-token
with:
client-id: ${{ vars.RELEASE_BOT_CLIENT_ID }}
private-key: ${{ secrets.RELEASE_BOT_PRIVATE_KEY }}
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: 20
- name: Install Dependencies
run: npm install
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v6
id: semantic # Need an `id` for output variables
env:
GITHUB_TOKEN: ${{ steps.release-bot-app-token.outputs.token }}
sync-to-develop:
needs: release
runs-on: ubuntu-latest
environment: Netlogix Release Bot
permissions:
contents: write
steps:
- name: Create GitHub App token
uses: actions/create-github-app-token@v3
id: release-bot-app-token
with:
client-id: ${{ vars.RELEASE_BOT_CLIENT_ID }}
private-key: ${{ secrets.RELEASE_BOT_PRIVATE_KEY }}
- name: Checkout (full history)
uses: actions/checkout@v7
with:
fetch-depth: 0
token: ${{ steps.release-bot-app-token.outputs.token }}
- name: Configure git & auth
run: |
git config user.name "${GIT_AUTHOR_NAME}"
git config user.email "${GIT_AUTHOR_EMAIL}"
git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git"
env:
GITHUB_TOKEN: ${{ steps.release-bot-app-token.outputs.token }}
- name: Fetch branches (heads only, no tags; avoid ambiguous refs)
run: |
set -euo pipefail
echo "Fetching main and develop branches..."
git fetch --no-tags --prune origin \
+refs/heads/main:refs/remotes/origin/main \
+refs/heads/develop:refs/remotes/origin/develop
- name: Sync composer.json & CHANGELOG.md from main to develop
id: sync
run: |
set -euo pipefail
echo "Configuring git user for pushing changes..."
git config user.email "websolutions@netlogix.de"
git config user.name "netlogix-bot"
echo "Checking for differences in composer.json and CHANGELOG.md between main and develop..."
if git diff --quiet \
refs/remotes/origin/develop..refs/remotes/origin/main \
-- composer.json CHANGELOG.md; then
echo "nothing_to_sync=true" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "Checking out develop branch..."
git checkout -B develop refs/remotes/origin/develop
echo "Checking out composer.json and CHANGELOG.md from main branch..."
git checkout refs/remotes/origin/main -- composer.json CHANGELOG.md
echo "Committing changes..."
git add composer.json CHANGELOG.md
git commit -m "[release-sync] chore: sync composer.json & CHANGELOG.md from main to develop [skip ci]" || {
echo "nothing_to_sync=true" >> "$GITHUB_OUTPUT"
exit 0
}
echo "Pushing changes to develop branch..."
git push origin HEAD:develop
echo "nothing_to_sync=false" >> "$GITHUB_OUTPUT"
echo "done"
env:
GITHUB_TOKEN: ${{ steps.release-bot-app-token.outputs.token }}
- name: Done
if: steps.sync.outputs.nothing_to_sync == 'true'
run: echo "Nichts zu syncen (composer.json/CHANGELOG.md identisch)."