WireMock Sync #65
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |