diff --git a/.github/workflows/qa-release.yml b/.github/workflows/qa-release.yml index 72653e4..c41641e 100644 --- a/.github/workflows/qa-release.yml +++ b/.github/workflows/qa-release.yml @@ -101,6 +101,7 @@ jobs: steps: - name: Push to protonova branch for Consumers uses: planningcenter/pco-release-action/deploy@v1 + if: ${{ !contains(github.event.comment.body, '--no-deploy') }} with: app-id: ${{ secrets.PCO_DEPENDENCIES_APP_ID }} private-key: ${{ secrets.PCO_DEPENDENCIES_PRIVATE_KEY }} @@ -114,9 +115,11 @@ jobs: allow-major: true package-json-path: ${{ inputs.package-json-path }} - name: Post results to original PR - uses: planningcenter/pco-release-action/qa-reporting@v1 + uses: planningcenter/pco-release-action/reporting@v1 with: pr-number: ${{ github.event.issue.number }} results-json: ${{ env.results_json }} + version-tag: ${{ needs.create-qa-release.outputs.release-tag }} actor: ${{ github.actor }} proto-tag: "${{ github.event.repository.name }}-${{ github.event.issue.number }}" + release-type: "QA" diff --git a/.github/workflows/release-candidate.yml b/.github/workflows/release-candidate.yml index 520b1f2..a4ac81f 100644 --- a/.github/workflows/release-candidate.yml +++ b/.github/workflows/release-candidate.yml @@ -101,6 +101,7 @@ jobs: steps: - name: Push to `staging` for Consumers uses: planningcenter/pco-release-action/deploy@v1 + if: ${{ !contains(github.event.comment.body, '--no-deploy') }} with: app-id: ${{ secrets.PCO_DEPENDENCIES_APP_ID }} private-key: ${{ secrets.PCO_DEPENDENCIES_PRIVATE_KEY }} @@ -114,8 +115,10 @@ jobs: allow-major: true package-json-path: ${{ inputs.package-json-path }} - name: Post results to original PR - uses: planningcenter/pco-release-action/rc-reporting@v1 + uses: planningcenter/pco-release-action/reporting@v1 with: pr-number: ${{ github.event.issue.number }} results-json: ${{ env.results_json }} + version-tag: ${{ needs.create-rc-release.outputs.release-tag }} actor: ${{ github.actor }} + release-type: "RC" diff --git a/create-qa-release/action.yml b/create-qa-release/action.yml index b848555..0f7928e 100644 --- a/create-qa-release/action.yml +++ b/create-qa-release/action.yml @@ -87,7 +87,7 @@ runs: run: | touch release_notes.md MODIFIED_COMMENT="${{ github.event.comment.body }}" - MODIFIED_COMMENT="${MODIFIED_COMMENT//@pco-release qa/}" + MODIFIED_COMMENT=$(echo "$MODIFIED_COMMENT" | sed -E 's/@pco-release[[:space:]]qa([[:space:]]--[^[:space:]]*)*[[:space:]]*//g') echo "QA build for #${{ github.event.issue.number }} $MODIFIED_COMMENT" > release_notes.md diff --git a/create-release-candidate/action.yml b/create-release-candidate/action.yml index d91025a..6eab563 100644 --- a/create-release-candidate/action.yml +++ b/create-release-candidate/action.yml @@ -84,7 +84,7 @@ runs: run: | touch release_notes.md MODIFIED_COMMENT="${{ github.event.comment.body }}" - MODIFIED_COMMENT="${MODIFIED_COMMENT//@pco-release rc/}" + MODIFIED_COMMENT=$(echo "$MODIFIED_COMMENT" | sed -E 's/@pco-release[[:space:]]rc([[:space:]]--[^[:space:]]*)*[[:space:]]*//g') echo "$MODIFIED_COMMENT" > release_notes.md - name: Create Release uses: ncipollo/release-action@v1 diff --git a/qa-reporting/action.yml b/qa-reporting/action.yml deleted file mode 100644 index db75db3..0000000 --- a/qa-reporting/action.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: Post results to original PR -inputs: - results-json: - description: "JSON string of results" - required: true - pr-number: - description: "The PR number that triggered the release" - required: true - actor: - description: "The actor that triggered the release" - required: true - proto-tag: - description: "The tag of the proto release" - required: true -runs: - using: "composite" - steps: - - uses: actions/github-script@v7 - env: - PR_NUMBER: ${{ inputs.pr-number }} - RESULTS_JSON: ${{ inputs.results-json }} - ACTOR: ${{ inputs.actor }} - PROTO_TAG: ${{ inputs.proto-tag }} - with: - script: | - const results = JSON.parse(process.env.RESULTS_JSON); - const successfulRepoList = results.successful_repos.map(repo => `- \`${repo.name}\``).join("\n") - const failedRepoList = results.failed_repos.map(repo => `- \`${repo.name}\`: ${repo.message}`).join("\n") - const body = `## QA release successfully created - - You can access the proto release at: https://${process.env.PROTO_TAG}.login.planningcenter.ninja/ - - ${results.successful_repos.length > 0 ? "### Deployed Successfully to the following repos:" : ""} - - ${successfulRepoList} - - ${results.failed_repos.length > 0 ? "### Failed to deploy in the following repos:" : ""} - - ${failedRepoList} - - Triggered by: @${process.env.ACTOR} - ` - github.rest.issues.createComment({ - issue_number: process.env.PR_NUMBER, - owner: context.repo.owner, - repo: context.repo.repo, - body: body - }); - - if (results.failed_repos.length > 0) { - throw new Error("Failed to push to all apps."); - } diff --git a/rc-reporting/action.yml b/rc-reporting/action.yml deleted file mode 100644 index 6cc5824..0000000 --- a/rc-reporting/action.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Post results to original PR -inputs: - results-json: - description: "JSON string of results" - required: true - pr-number: - description: "The PR number that triggered the release" - required: true - actor: - description: "The actor that triggered the release" - required: true -runs: - using: "composite" - steps: - - uses: actions/github-script@v7 - env: - PR_NUMBER: ${{ inputs.pr-number }} - RESULTS_JSON: ${{ inputs.results-json }} - ACTOR: ${{ inputs.actor }} - with: - script: | - const results = JSON.parse(process.env.RESULTS_JSON); - const successfulRepoList = results.successful_repos.map(repo => `- \`${repo.name}\``).join("\n") - const failedRepoList = results.failed_repos.map(repo => `- \`${repo.name}\`: ${repo.message}`).join("\n") - const body = `## RC successfully created - - ${results.successful_repos.length > 0 ? "### Deployed Successfully to the following repos:" : ""} - - ${successfulRepoList} - - ${results.failed_repos.length > 0 ? "### Failed to deploy in the following repos:" : ""} - - ${failedRepoList} - - Triggered by: @${process.env.ACTOR} - ` - github.rest.issues.createComment({ - issue_number: process.env.PR_NUMBER, - owner: context.repo.owner, - repo: context.repo.repo, - body: body - }); - - if (results.failed_repos.length > 0) { - throw new Error("Failed to push to all apps."); - } diff --git a/reporting/action.yml b/reporting/action.yml new file mode 100644 index 0000000..f870877 --- /dev/null +++ b/reporting/action.yml @@ -0,0 +1,77 @@ +name: Post results to original PR +inputs: + results-json: + description: "JSON string of results" + required: true + pr-number: + description: "The PR number that triggered the release" + required: true + actor: + description: "The actor that triggered the release" + required: true + version-tag: + description: "The tag of the version release" + required: true + release-type: + description: "The type of release" + required: true + proto-tag: + description: "The tag of the proto release (if it exists)" + required: false +runs: + using: "composite" + steps: + - uses: actions/github-script@v7 + env: + PR_NUMBER: ${{ inputs.pr-number }} + RESULTS_JSON: ${{ inputs.results-json }} + ACTOR: ${{ inputs.actor }} + VERSION_TAG: ${{ inputs.version-tag }} + RELEASE_TYPE: ${{ inputs.release-type }} + with: + script: | + function getBody() { + if (!process.env.RESULTS_JSON) return "" + const results = JSON.parse(process.env.RESULTS_JSON); + const successfulRepoList = results.successful_repos.map(repo => `- \`${repo.name}\``).join("\n") + const failedRepoList = results.failed_repos.map(repo => `- \`${repo.name}\`: ${repo.message}`).join("\n") + return ` + ${process.env.PROTO_TAG ? "You can access the proto release at: https://${process.env.PROTO_TAG}.login.planningcenter.ninja/" : ""} + + ${results.successful_repos.length > 0 ? "### Deployed Successfully to the following repos:" : ""} + + ${successfulRepoList} + + ${results.failed_repos.length > 0 ? "### Failed to deploy in the following repos:" : ""} + + ${failedRepoList} + + ` + } + + function getFailed() { + if (!process.env.RESULTS_JSON) return false + const results = JSON.parse(process.env.RESULTS_JSON); + return results.failed_repos.length > 0 + } + + function getHeader() { + return `## ${process.env.RELEASE_TYPE} release ${process.env.VERSION_TAG} successfully created` + } + + const header = getHeader() + const body = getBody() + const footer = `Triggered by: @${process.env.ACTOR}` + + github.rest.issues.createComment({ + issue_number: process.env.PR_NUMBER, + owner: context.repo.owner, + repo: context.repo.repo, + body: `${header} + ${body} + ${footer}` + }); + + if (getFailed()) { + throw new Error("Failed to push to all apps."); + }