From 77cb3a0aa648e4401dfa1e35a01512676f2ca117 Mon Sep 17 00:00:00 2001 From: Xikaro Date: Fri, 25 Jul 2025 23:07:36 +0500 Subject: [PATCH] workflows --- .github/workflows/build.yml | 55 --------------------- .github/workflows/create-pr.yml | 84 +++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 55 deletions(-) create mode 100644 .github/workflows/create-pr.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 94e8548eb..f1f67dc30 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -208,61 +208,6 @@ jobs: ${{ steps.changelog_dev.outputs.description }} ${{ steps.format_diff.outputs.text }} - - # create-pr: - # name: 🤝 Create Release PR - # needs: [info] - # runs-on: ubuntu-latest - # if: ${{ needs.info.outputs.make_pr == 'true' }} - # steps: - - # - name: đŸ“Ļ Checkout - # uses: actions/checkout@v4.2.2 - - # - name: 🔍 Check existing PRs - # id: check_existing_pr - # uses: actions/github-script@v7.0.1 - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # with: - # script: | - # try { - # const { data: prs } = await github.rest.pulls.list({ - # owner: context.repo.owner, - # repo: context.repo.repo, - # state: 'open', - # head: `${context.repo.owner}:dev`, - # base: 'main' - # }); - - # if (prs.length > 0) { - # console.log(`â„šī¸ Found existing PR from dev to main: ${prs[0].html_url}`); - # core.setOutput('exists', 'true'); - # } else { - # core.setOutput('exists', 'false'); - # } - # } catch (error) { - # core.setFailed(`❌ Failed to check existing PRs: ${error}`); - # core.setOutput('exists', 'error'); - # } - - - # - name: 📄 Create Pull Request if tag not found - # if: ${{ steps.check_existing_pr.outputs.exists == 'false' }} - # uses: devops-infra/action-pull-request@v0.6.0 - # with: - # github_token: ${{ secrets.GITHUB_TOKEN }} - # source_branch: dev - # target_branch: main - # reviewer: Xikaro - # ignore_users: "dependabot" - # title: 'Release: ${{ needs.info.outputs.project_version }}' - # body: | - # **This is an automated Pull Request from the dev branch.** - # 📃 **Name**: ${{ needs.info.outputs.project_name }} - # 📃 **Release**: `${{ needs.info.outputs.project_version }}` - # 📃 **Release Type**: `${{ needs.info.outputs.release_type }}` - # 📃 **Game Version**: `${{ needs.info.outputs.mc_version }}` build-modpack: diff --git a/.github/workflows/create-pr.yml b/.github/workflows/create-pr.yml new file mode 100644 index 000000000..e9322fa11 --- /dev/null +++ b/.github/workflows/create-pr.yml @@ -0,0 +1,84 @@ +name: Project Build +run-name: "👾 Create Release PR" +on: + push: + branches: + - dev + paths-ignore: + - '**' + - '!CHANGELOG.md' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + create-pr: + name: 🤝 Create Release PR + runs-on: ubuntu-latest + steps: + + - name: Checkout + uses: actions/checkout@v4.2.2 + + - name: 📊 Get Pakku Info + id: pakku_info + uses: ActionsTools/read-json-action@v1.0.5 + with: + file_path: "pakku.json" + + - name: 📊 Get Pakku-lock Info + id: pakku_lock_info + uses: ActionsTools/read-json-action@v1.0.5 + with: + file_path: "pakku-lock.json" + + - name: 📄 Changelog Parser + id: changelog + uses: coditory/changelog-parser@v1.0.2 + with: + path: CHANGELOG.md + continue-on-error: true + + - name: 🔍 Check if tag exists + uses: mukunku/tag-exists-action@v1.6.0 + id: check_tag + with: + tag: ${{ steps.changelog.outputs.version }} + + - name: 🔍 Check existing PRs + if: ${{ steps.check_tag.outputs.exists == 'false' }} + id: check_existing_pr + uses: actions/github-script@v7.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + script: | + const { data: prs } = await github.rest.pulls.list({ + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open', + head: `${context.repo.owner}:dev`, + base: 'main' + }); + + if (prs.length > 0) { + console.log(`â„šī¸ Found existing PR from dev to main: ${prs[0].html_url}`); + core.setOutput('exists', 'true'); + } else { + core.setOutput('exists', 'false'); + } + + - name: 🔍 Create Pull Request if tag not found + if: ${{ !steps.check_existing_pr.outputs.exists }} + uses: devops-infra/action-pull-request@v0.6.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + source_branch: dev + target_branch: main + title: 'Release: ${{ steps.changelog.outputs.version }}' + body: | + **This is an automated Pull Request from the dev branch.** + 📃 **Name**: ${{ steps.pakku_info.outputs.name }} + 📃 **Release**: `${{ steps.changelog.outputs.version }}` + 📃 **Release Type**: `${{ steps.pakku_info.outputs.release_type }}` \ No newline at end of file