diff --git a/.github/workflows/sdk_merge.yaml b/.github/workflows/sdk_merge.yaml index dc47b294..07acab82 100644 --- a/.github/workflows/sdk_merge.yaml +++ b/.github/workflows/sdk_merge.yaml @@ -17,17 +17,26 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 environment: sdk-release + outputs: + notify: ${{ steps.bot.outputs.notify }} + pr: ${{ steps.bot.outputs.pr }} steps: - id: bot - uses: gr4vy/sdk-release/release-bot@f956131fcbeaa05d2afcd763f7f8e8122ed823e2 + uses: gr4vy/sdk-release/release-bot@4d17bbfa966f12d70db408bb1d0acc30576e0647 with: sdk: python run-id: ${{ github.event.workflow_run.id }} client-id: ${{ secrets.SDK_RELEASE_APP_CLIENT_ID }} private-key: ${{ secrets.SDK_RELEASE_APP_PRIVATE_KEY }} + # Kept out of `decide`, which holds the release App key: the Slack action + # runs a container image. + notify: + needs: decide + if: needs.decide.outputs.notify == 'true' + runs-on: ubuntu-latest + steps: - name: Slack Notification - if: steps.bot.outputs.notify == 'true' uses: rtCamp/action-slack-notify@e31e87e03dd19038e411e38ae27cbad084a90661 # v2 env: SLACK_USERNAME: Python SDK @@ -37,5 +46,5 @@ jobs: SLACK_MSG_AUTHOR: gr4vy SLACK_ICON_EMOJI: ":gr4vy-sdk:" SLACK_COLOR: "warning" - SLACK_MESSAGE: "Speakeasy PR needs a human: ${{ github.server_url }}/${{ github.repository }}/pull/${{ steps.bot.outputs.pr }}" + SLACK_MESSAGE: "Speakeasy PR needs a human: ${{ github.server_url }}/${{ github.repository }}/pull/${{ needs.decide.outputs.pr }}" SLACK_FOOTER: "" diff --git a/.github/workflows/sdk_publish.yaml b/.github/workflows/sdk_publish.yaml index 4bac4474..858c496e 100644 --- a/.github/workflows/sdk_publish.yaml +++ b/.github/workflows/sdk_publish.yaml @@ -25,6 +25,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 permissions: + actions: read contents: read pull-requests: read outputs: @@ -32,8 +33,20 @@ jobs: mode: ${{ github.event_name == 'workflow_dispatch' && 'manual' || steps.gate.outputs.mode }} version: ${{ steps.gate.outputs.version }} steps: + - name: Require a green CI run on this commit + if: github.event_name == 'workflow_dispatch' + env: + GH_TOKEN: ${{ github.token }} + SHA: ${{ github.sha }} + run: | + passed=$(gh api "repos/$GITHUB_REPOSITORY/actions/workflows/ci.yaml/runs?head_sha=$SHA&branch=main&event=push&status=success" --jq '.total_count') + if [ "$passed" = "0" ]; then + echo "::error::CI hasn't passed on main for $SHA, so it can't be released" + exit 1 + fi + - id: gate - uses: gr4vy/sdk-release/publish-gate@f956131fcbeaa05d2afcd763f7f8e8122ed823e2 + uses: gr4vy/sdk-release/publish-gate@4d17bbfa966f12d70db408bb1d0acc30576e0647 with: head-sha: ${{ github.event.workflow_run.head_sha || github.sha }} bot-login: gr4vy-sdk-release[bot]