mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-06-16 04:35:24 +02:00
69 lines
2.6 KiB
YAML
69 lines
2.6 KiB
YAML
name: Auto PR to main when version changes
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- canary
|
|
|
|
jobs:
|
|
create-pr:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout Repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Get version from package.json
|
|
id: package_version
|
|
run: echo "VERSION=$(jq -r .version ./apps/dokploy/package.json)" >> $GITHUB_ENV
|
|
|
|
- name: Get latest GitHub tag
|
|
id: latest_tag
|
|
run: |
|
|
LATEST_TAG=$(git ls-remote --tags origin | awk -F'/' '{print $3}' | sort -V | tail -n1)
|
|
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
|
|
echo $LATEST_TAG
|
|
- name: Compare versions
|
|
id: compare_versions
|
|
run: |
|
|
if [ "${{ env.VERSION }}" != "${{ env.LATEST_TAG }}" ]; then
|
|
VERSION_CHANGED="true"
|
|
else
|
|
VERSION_CHANGED="false"
|
|
fi
|
|
echo "VERSION_CHANGED=$VERSION_CHANGED" >> $GITHUB_ENV
|
|
echo "Comparing versions:"
|
|
echo "Current version: ${{ env.VERSION }}"
|
|
echo "Latest tag: ${{ env.LATEST_TAG }}"
|
|
echo "Version changed: $VERSION_CHANGED"
|
|
- name: Check if a PR already exists
|
|
id: check_pr
|
|
run: |
|
|
PR_EXISTS=$(gh pr list --state open --base main --head canary --json number --jq '. | length')
|
|
echo "PR_EXISTS=$PR_EXISTS" >> $GITHUB_ENV
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GH_PAT }}
|
|
|
|
- name: Create Pull Request
|
|
if: env.VERSION_CHANGED == 'true' && env.PR_EXISTS == '0'
|
|
run: |
|
|
git config --global user.name "GitHub Actions"
|
|
git config --global user.email "actions@github.com"
|
|
|
|
git fetch origin main
|
|
git checkout -b release/${{ env.VERSION }}
|
|
git push origin release/${{ env.VERSION }}
|
|
|
|
gh pr create \
|
|
--title "🚀 Release ${{ env.VERSION }}" \
|
|
--body "## 🔄 Release ${{ env.VERSION }}\n\nThis PR promotes changes from \`canary\` to \`main\` for version v${{ env.VERSION }}.\n\n### 🔍 Changes Include:\n- Version bump to v${{ env.VERSION }}\n- All changes from canary branch\n\n### ✅ Pre-merge Checklist:\n- [ ] All tests passing\n- [ ] Documentation updated\n- [ ] Docker images built and tested\n\n> 🤖 This PR was automatically generated by [GitHub Actions](https://github.com/actions)." \
|
|
--base main \
|
|
--head release/${{ env.VERSION }} \
|
|
--draft \
|
|
--label "release" --label "automated pr" \
|
|
--reviewer siumauricio \
|
|
--assignee siumauricio
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GH_PAT }}
|