Skip to content

Commit

Permalink
job
Browse files Browse the repository at this point in the history
Signed-off-by: Lukasz Dziedziak <lukidzi@gmail.com>
  • Loading branch information
lukidzi authored and actions-user committed Nov 8, 2024
1 parent 8b0a985 commit 01e16e1
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/scripts/get-version-tags.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

current_tag=$(git tag --list --merged origin/release --sort=-creatordate | head -n 1)
main_tag=$(git tag --list --merged main --sort=-creatordate | head -n 1)

# Remove the prefix `v` and `-kong-*` suffix for comparison
released_tag="${current_tag%-ld-*}"
currentVersion="${released_tag#v}"

# Main branch won't have -kong-* suffix
newVersion="${main_tag#v}"

# Convert versions to arrays
IFS='.' read -r -a currentParts <<< "$currentVersion"
IFS='.' read -r -a newParts <<< "$newVersion"

echo "released_tag=$released_tag" >> $GITHUB_OUTPUT
echo "main_tag=$main_tag" >> $GITHUB_OUTPUT

# Compare each part
for i in 0 1 2; do
if [[ ${newParts[i]:-0} -gt ${currentParts[i]:-0} ]]; then
echo "The new tag is higher."
newVersionTag="${main_tag}-ld-1"
echo "New version tag: $newVersionTag"
echo "new_tag=$newVersionTag" >> $GITHUB_OUTPUT
exit 0
elif [[ ${newParts[i]:-0} -lt ${currentParts[i]:-0} ]]; then
echo "The current tag is higher. That shouldn't be that case, please fix tagging."
exit 1
fi
done

echo "The tags are equal."
exit 0
62 changes: 62 additions & 0 deletions .github/workflows/sync-fork.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: 'Sync with Upstream'

on:
schedule:
- cron: '0 6 * * *'
#scheduled at 06:00 everyday
workflow_dispatch: {}

permissions:
actions: write
contents: write

jobs:
sync-with-upstream-main:
runs-on: ubuntu-latest
name: Sync with upstream main
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
fetch-depth: 0
token: ${{ secrets.WORKFLOW_TOKEN }}
- name: Sync upstream changes
id: sync
uses: aormsby/Fork-Sync-With-Upstream-action@v3.4.1
with:
target_sync_branch: main
target_repo_token: ${{ secrets.WORKFLOW_TOKEN }}
target_branch_push_args: "-f --tags"
upstream_sync_branch: main
upstream_sync_repo: envoyproxy/go-control-plane
upstream_pull_args: "--tags"
test_mode: false
git_config_pull_rebase: true
- run: |
git config --global user.email "lukidzi@users.noreply.github.com"
git config --global user.name "lukidzi"
- name: New commits found
if: steps.sync.outputs.has_new_commits == 'true'
run: echo "New commits were found to sync."

- name: No new commits
if: steps.sync.outputs.has_new_commits == 'false'
run: echo "There were no new commits."
- name: Get new version tag
id: new-version-tag
if: steps.sync.outputs.has_new_commits == 'true'
shell: bash
run: ".github/scripts/get-version-tags.sh"
- name: Print tags
run: |
echo ${{ steps.new-version-tag.outputs.released_tag }}
echo ${{ steps.new-version-tag.outputs.main_tag }}
echo ${{ steps.new-version-tag.outputs.new_tag }}
- name: Release new version
if: steps.new-version-tag.outputs.released_tag != steps.new-version-tag.outputs.main_tag
run: |
git remote -v
git checkout release
git pull
git rebase --onto ${{ steps.new-version-tag.outputs.main_tag }} ${{ steps.new-version-tag.outputs.released_tag }} release
git tag ${{ steps.new-version-tag.outputs.new_tag }}
git push origin release --tags -f

0 comments on commit 01e16e1

Please sign in to comment.