From 01f1ec6d915fb02513b1dcce2c3b95a5ab731744 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Wed, 25 Jun 2025 00:00:38 +0300 Subject: [PATCH 1/3] Feature release shared workflow --- .../workflows/shared-go-feature-release.yml | 175 ++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 .github/workflows/shared-go-feature-release.yml diff --git a/.github/workflows/shared-go-feature-release.yml b/.github/workflows/shared-go-feature-release.yml new file mode 100644 index 00000000..6ab343f7 --- /dev/null +++ b/.github/workflows/shared-go-feature-release.yml @@ -0,0 +1,175 @@ +name: "Shared Go Feature release" + +on: + workflow_call: + inputs: + runs-on: + description: "Overrides job runs-on setting (json-encoded list)" + type: string + required: false + default: '["ubuntu-latest"]' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false + +defaults: + run: + # We need -e -o pipefail for consistency with GitHub Actions's default behavior + shell: bash -e -o pipefail {0} + +jobs: + access: + if: ${{ github.event.issue.pull_request && + contains(github.event.comment.body, '/release') && + github.event.issue.state == 'open' }} + uses: cloudposse/.github/.github/workflows/shared-access-controller.yml@main + with: + runs-on: ${{ inputs.runs-on }} + permission: create_feature_releases + user: ${{ github.event.comment.user.login }} + + context: + name: Context + needs: [access] + if: ${{ needs.access.outputs.granted == 'true' }} + runs-on: ${{ fromJSON(inputs.runs-on) }} + steps: + - uses: cloudposse-github-actions/get-pr@v2 + id: pr + with: + id: ${{ github.event.issue.number }} + + - uses: actions/github-script@v7 + id: properties + with: + result-encoding: string + script: | + const properites = await github.request('GET /repos/{owner}/{repo}/properties/values', { + owner: context.repo.owner, + repo: context.repo.repo, + headers: { + 'X-GitHub-Api-Version': '2022-11-28' + } + }) + + properites.data.forEach((element) => + core.setOutput(element.property_name, element.value) + ); + + outputs: + base: ${{ fromJSON(steps.pr.outputs.json).base.sha }} + base_repo_owner: ${{ fromJSON(steps.pr.outputs.json).base.repo.owner.login }} + base_repo_name: ${{ fromJSON(steps.pr.outputs.json).base.repo.name }} + head_sha: ${{ fromJSON(steps.pr.outputs.json).head.sha }} + head_repo_owner: ${{ fromJSON(steps.pr.outputs.json).head.repo.owner.login }} + head_repo_name: ${{ fromJSON(steps.pr.outputs.json).head.repo.name }} + found: ${{ steps.pr.outputs.found }} + json: ${{ steps.pr.outputs.json }} + number: ${{ steps.pr.outputs.number }} + title: ${{ steps.pr.outputs.title }} + body: ${{ steps.pr.outputs.body }} + url: ${{ steps.pr.outputs.url }} + created_at: ${{ steps.pr.outputs.created_at }} + merged_at: ${{ steps.pr.outputs.merged_at }} + closed_at: ${{ steps.pr.outputs.closed_at }} + labels: ${{ steps.pr.outputs.labels }} + terratest_aws_role: ${{ steps.properties.outputs.test-aws-role || 'arn:aws:iam::799847381734:role/cptest-test-ue2-sandbox-gha-iam-terratest' }} + terratest_skip_concurrency: ${{ steps.properties.outputs.test-skip-concurrency }} + + ack: + if: github.event.comment.id != '' + needs: [context] + runs-on: ${{ fromJSON(inputs.runs-on) }} + steps: + - name: "Add reaction" + uses: peter-evans/create-or-update-comment@v4 + with: + repository: ${{ needs.context.outputs.base_repo_owner }}/${{ needs.context.outputs.base_repo_name }} + comment-id: ${{ github.event.comment.id }} + token: ${{ github.token }} + reactions: '+1' + + pending: + needs: [context] + runs-on: ${{ fromJSON(inputs.runs-on) }} + steps: + - name: "Update GitHub Status for pending" + uses: docker://cloudposse/github-status-updater + with: + args: >- + -action update_state + -ref "${{ needs.context.outputs.head_sha }}" + -owner "${{ needs.context.outputs.base_repo_owner }}" + -repo "${{ needs.context.outputs.base_repo_name }}" + -state pending + -context "feature/release" + -description "Feature release creation started by @${{ github.actor }}" + -url "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + env: + GITHUB_TOKEN: ${{ github.token }} + + release: + needs: [pending] + uses: cloudposse/.github/.github/workflows/shared-go-auto-release.yml@main + with: + publish: true + prerelease: true + format: binary + environment: 'feature-releases' + secrets: inherit + + finalize: + needs: [release, context] + if: ${{ always() }} + runs-on: ${{ fromJSON(inputs.runs-on) }} + steps: + - name: "Update GitHub Status for failure" + if: ${{ failure() }} + uses: docker://cloudposse/github-status-updater + with: + args: >- + -action update_state + -ref "${{ needs.context.outputs.head_sha }}" + -owner "${{ needs.context.outputs.base_repo_owner }}" + -repo "${{ needs.context.outputs.base_repo_name }}" + -state failure + -context "feature/release" + -description "Feature release creation failed" + -url "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + env: + GITHUB_TOKEN: ${{ github.token }} + + - name: "Update GitHub Status for cancelled" + if: ${{ canceled() }} + uses: docker://cloudposse/github-status-updater + with: + args: >- + -action update_state + -ref "${{ needs.context.outputs.head_sha }}" + -owner "${{ needs.context.outputs.base_repo_owner }}" + -repo "${{ needs.context.outputs.base_repo_name }}" + -state failure + -context "feature/release" + -description "Feature release creation canceled" + -url "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + env: + GITHUB_TOKEN: ${{ github.token }} + + - name: "Update GitHub Status for this success" + if: ${{ success() }} + uses: docker://cloudposse/github-status-updater + with: + args: >- + -action update_state + -ref "${{ needs.context.outputs.head_sha }}" + -owner "${{ needs.context.outputs.base_repo_owner }}" + -repo "${{ needs.context.outputs.base_repo_name }}" + -state success + -context "feature/release" + -description "TFeature release created" + -url "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + env: + GITHUB_TOKEN: ${{ github.token }} + + From f5dbcc662864d5f39920a133a4a2896395c652fa Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Wed, 25 Jun 2025 00:56:12 +0300 Subject: [PATCH 2/3] Update shared-go-feature-release.yml --- .github/workflows/shared-go-feature-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/shared-go-feature-release.yml b/.github/workflows/shared-go-feature-release.yml index 6ab343f7..b93261b4 100644 --- a/.github/workflows/shared-go-feature-release.yml +++ b/.github/workflows/shared-go-feature-release.yml @@ -141,7 +141,7 @@ jobs: GITHUB_TOKEN: ${{ github.token }} - name: "Update GitHub Status for cancelled" - if: ${{ canceled() }} + if: ${{ cancelled() }} uses: docker://cloudposse/github-status-updater with: args: >- @@ -151,7 +151,7 @@ jobs: -repo "${{ needs.context.outputs.base_repo_name }}" -state failure -context "feature/release" - -description "Feature release creation canceled" + -description "Feature release creation cancelled" -url "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" env: GITHUB_TOKEN: ${{ github.token }} From 536db5e4580688614c304d35054fa71355fe8cc8 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Wed, 25 Jun 2025 01:49:45 +0300 Subject: [PATCH 3/3] Update shared-auto-release.yml --- .github/workflows/shared-auto-release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/shared-auto-release.yml b/.github/workflows/shared-auto-release.yml index fc13f66c..26c26fc4 100644 --- a/.github/workflows/shared-auto-release.yml +++ b/.github/workflows/shared-auto-release.yml @@ -133,6 +133,7 @@ jobs: with: result-encoding: string retries: 3 + github-token: ${{ steps.github-app.outputs.token }} script: | // Function to create or update a comment for a pull request (PR) associated with a release async function createCommentForPR(pr_id, release) {