|
| 1 | +name: Auto PR to main when version changes |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - canary |
| 7 | + |
| 8 | +jobs: |
| 9 | + create-pr: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - name: Checkout Repository |
| 13 | + uses: actions/checkout@v4 |
| 14 | + with: |
| 15 | + fetch-depth: 0 |
| 16 | + |
| 17 | + - name: Get version from package.json |
| 18 | + id: package_version |
| 19 | + run: echo "VERSION=$(jq -r .version ./apps/dokploy/package.json)" >> $GITHUB_ENV |
| 20 | + |
| 21 | + - name: Get latest GitHub tag |
| 22 | + id: latest_tag |
| 23 | + run: | |
| 24 | + LATEST_TAG=$(git ls-remote --tags origin | awk -F'/' '{print $3}' | sort -V | tail -n1) |
| 25 | + echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV |
| 26 | + echo $LATEST_TAG |
| 27 | + - name: Compare versions |
| 28 | + id: compare_versions |
| 29 | + run: | |
| 30 | + if [ "${{ env.VERSION }}" != "${{ env.LATEST_TAG }}" ]; then |
| 31 | + VERSION_CHANGED="true" |
| 32 | + else |
| 33 | + VERSION_CHANGED="false" |
| 34 | + fi |
| 35 | + echo "VERSION_CHANGED=$VERSION_CHANGED" >> $GITHUB_ENV |
| 36 | + echo "Comparing versions:" |
| 37 | + echo "Current version: ${{ env.VERSION }}" |
| 38 | + echo "Latest tag: ${{ env.LATEST_TAG }}" |
| 39 | + echo "Version changed: $VERSION_CHANGED" |
| 40 | + - name: Check if a PR already exists |
| 41 | + id: check_pr |
| 42 | + run: | |
| 43 | + PR_EXISTS=$(gh pr list --state open --base main --head canary --json number --jq '. | length') |
| 44 | + echo "PR_EXISTS=$PR_EXISTS" >> $GITHUB_ENV |
| 45 | + env: |
| 46 | + GH_TOKEN: ${{ secrets.GH_PAT }} |
| 47 | + |
| 48 | + - name: Create Pull Request |
| 49 | + if: env.VERSION_CHANGED == 'true' && env.PR_EXISTS == '0' |
| 50 | + uses: peter-evans/create-pull-request@v7 |
| 51 | + with: |
| 52 | + token: ${{ secrets.GH_PAT }} |
| 53 | + title: "🚀 Release v${{ env.VERSION }}" |
| 54 | + body: | |
| 55 | + ## 🔄 Release v${{ env.VERSION }} |
| 56 | + This PR promotes changes from `canary` to `main` for version v${{ env.VERSION }}. |
| 57 | + ### 🔍 Changes Include: |
| 58 | + - Version bump to v${{ env.VERSION }} |
| 59 | + - All changes from canary branch |
| 60 | + ### ✅ Pre-merge Checklist: |
| 61 | + - [ ] All tests passing |
| 62 | + - [ ] Documentation updated |
| 63 | + - [ ] Docker images built and tested |
| 64 | + > 🤖 This PR was automatically generated from the canary branch |
| 65 | + base: main |
| 66 | + branch: canary |
| 67 | + draft: true |
| 68 | + labels: | |
| 69 | + release |
| 70 | + automated pr |
| 71 | + reviewers: | |
| 72 | + siumauricio |
| 73 | + assignees: | |
| 74 | + siumauricio |
| 75 | + delete-branch: false |
0 commit comments