From 439a3564465256083af8a35d00c9e82f43e5e47c Mon Sep 17 00:00:00 2001 From: Xikaro Date: Fri, 25 Jul 2025 22:28:11 +0500 Subject: [PATCH] Update build.yml --- .github/workflows/build.yml | 70 +++++++++++++++++++++++++------------ 1 file changed, 47 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e267b1a1e..92e61fc39 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,11 +12,13 @@ concurrency: env: DEV_ENVIRONMENT: ${{ github.ref_name != 'main' }} + IS_REPO_OWNER: ${{ github.repository_owner == 'TerraFirmaGreg-Team' }} jobs: info: name: 🖥️ Project Info runs-on: ubuntu-latest + if: ${{ env.IS_REPO_OWNER }} outputs: project_version: ${{ steps.check.outputs.project_version }} project_name: ${{ steps.check.outputs.project_name }} @@ -27,6 +29,7 @@ jobs: diff: ${{ steps.read_diff.outputs.diff }} exists: ${{ steps.check.outputs.exists }} make_release: ${{ steps.check.outputs.make_release }} + make_pr: ${{ steps.check.outputs.make_pr }} steps: - name: Checkout @@ -161,8 +164,6 @@ jobs: id: check shell: bash run: | - echo "make_release=${{ steps.check_tag.outputs.exists == 'false' && env.DEV_ENVIRONMENT == 'false' }}" >> $GITHUB_OUTPUT - echo "exists=${{ steps.check_tag.outputs.exists }}" >> $GITHUB_OUTPUT echo "project_name=${{ steps.pakku_info.outputs.name }}" >> $GITHUB_OUTPUT MC_VERSIONS_JSON='${{ steps.pakku_lock_info.outputs.mc_versions }}' MINECRAFT_VERSION=$(echo "$MC_VERSIONS_JSON" | jq -r '.[0]' | tr -d '[]"') @@ -176,6 +177,9 @@ jobs: echo "release_type=${{ steps.pakku_info.outputs.release_type }}" >> $GITHUB_OUTPUT fi + echo "make_release=${{ steps.check_tag.outputs.exists == 'false' && env.DEV_ENVIRONMENT == 'false' }}" >> $GITHUB_OUTPUT + echo "make_pr=${{ steps.check_tag.outputs.exists == 'false' && env.DEV_ENVIRONMENT == 'true' }}" >> $GITHUB_OUTPUT + - name: 📄 Format diff id: format_diff if: ${{ steps.read_diff.outputs.diff != '' }} @@ -186,29 +190,9 @@ jobs: ${{ steps.read_diff.outputs.diff }} ``` - # - name: 🔍 Create Pull Request if tag not found - # id: create_pr - # if: ${{ steps.check_tag.outputs.exists == 'false' && env.DEV_ENVIRONMENT == 'true' && github.repository_owner == 'TerraFirmaGreg-Team' }} - # 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.check.outputs.project_name }} - # 📃 **Release**: `${{ steps.changelog.outputs.version }}` - # 📃 **Release Type**: `${{ steps.pakku_info.outputs.release_type }}` - # 📃 **Game Version**: `${{ steps.check.outputs.minecraft_version }}` - - # ${{ steps.changelog.outputs.description }} - # reviewer: Xikaro - # ignore_users: "dependabot" - name: 📝 Generate Github Summary - uses: WcAServices/markdown-template-action@v1.1.1 + uses: WcAServices/markdown-template-action@v1.1.0 with: template: | 📃 **Name**: ${{ steps.check.outputs.project_name }} @@ -218,11 +202,51 @@ jobs: 📃 **Dev Environment**: `${{ env.DEV_ENVIRONMENT }}` 📃 **Tag Exists**: `${{ steps.check.outputs.exists }}` + 📃 **Make Pull Request**: `${{ steps.check.outputs.make_pr }}` 📃 **Make Release**: `${{ steps.check.outputs.make_release }}` ${{ 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' && needs.info.outputs.release_type != 'Unreleased' }} + steps: + + - name: 🔍 Check existing PRs + id: check_existing_pr + uses: actions/github-script@v7.0.1 + with: + script: | + const { data: prs } = await github.rest.pulls.list({ + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open', + head: 'dev', + base: 'main' + }); + + return prs.length > 0; + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: 📄 Create Pull Request if tag not found + if: ${{ !steps.check_existing_pr.outputs.result }} + uses: devops-infra/action-pull-request@v0.6.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + source_branch: dev + target_branch: main + 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: