forked from wiremock/wiremock
-
Notifications
You must be signed in to change notification settings - Fork 33
79 lines (66 loc) · 2.89 KB
/
wiremock-sync.yml
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
name: WireMock Sync
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
jobs:
sync:
runs-on: ubuntu-latest
name: WireMock Sync
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: wiremock-remote
name: Add WireMock remote
run: |
#!/bin/bash
git remote add upstream https://github.com/wiremock/wiremock.git
git fetch upstream
- id: version-check
name: Check Versions
env:
GH_TOKEN: ${{ github.token }}
run: |
#!/bin/bash
# Check latest semver tag:
echo "Searching for latest semver"
wiremockVersion=$(git tag -l --sort=-version:refname | grep -P '^\d+\.\d+\.\d+$' -m 1)
echo "wiremockVersion=${wiremockVersion}" >> $GITHUB_OUTPUT
echo "Found wiremockVersion=${wiremockVersion}"
guiVersion=$(gh release list --exclude-drafts --exclude-pre-releases --repo holomekc/wiremock | grep "Latest" | awk '{print $1}')
echo "guiVersion=${guiVersion}" >> $GITHUB_OUTPUT
echo "Found guiVersion=${guiVersion}"
echo "Checking if WireMock version != WireMock-Gui version."
echo "${wiremockVersion} != ${guiVersion}"
[[ $guiVersion = ${wiremockVersion}* ]] && newVersion=0 || newVersion=1
echo "newVersion=${newVersion}" >> $GITHUB_OUTPUT
if [[ $newVersion == 0 ]]
then
echo "No new version found. Nothing to do."
else
echo "A new version ${wiremockVersion} found."
fi
- id: create-pr
if: ${{ steps.version-check.outputs.newVersion == 1 }}
name: Create PR
env:
GH_TOKEN: ${{ github.token }}
run: |
#!/bin/bash
wiremockVersion=${{ steps.version-check.outputs.wiremockVersion }}
# Let us try to resolve conflicts "automatically".
# We start with a new branch from our master branch
git branch sync/${wiremockVersion}
# Then we merge the new tag. This will create at least one expected conflict
git merge ${wiremockVersion}
# We try to automatically resolve the version conflict
sed -i '/<<<<<<< HEAD/,/=======/d' build.gradle
sed -i '/>>>>>>> ${wiremockVersion}/d' build.gradle
sed -i "s/version = '${wiremockVersion}'/version = '${wiremockVersion}.0'/g" build.gradle
# Then we accept everything else and maybe the build is ok or not and need manual adjustments
git add -u
git commit -m "Merge tag ${wiremockVersion} into master."
git push
# Create pull request and hope for the best.
gh pr create --repo holomekc/wiremock --base master --body "WireMock version=${wiremockVersion} sync." --head sync/${wiremockVersion} --label enhancement --reviewer holomekc --title "WireMock version=${wiremockVersion} sync"