From cb1787a9b9e96b276d38d29c7d080374a6381a48 Mon Sep 17 00:00:00 2001 From: Ringo De Smet Date: Wed, 14 Aug 2024 12:20:25 +0200 Subject: [PATCH 1/5] Hackathon: dispatch SDK build to pulumi/pulumi-sdk repo --- .github/workflows/dispatch_build_sdk.yml | 51 ++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/dispatch_build_sdk.yml diff --git a/.github/workflows/dispatch_build_sdk.yml b/.github/workflows/dispatch_build_sdk.yml new file mode 100644 index 00000000..444fd29a --- /dev/null +++ b/.github/workflows/dispatch_build_sdk.yml @@ -0,0 +1,51 @@ +name: dispatch-build-sdk +on: + workflow_dispatch: + inputs: + sdk_version: + description: 'SDK version to build' + required: true + +jobs: + prerequisites: + uses: ./.github/workflows/prerequisites.yml + secrets: inherit + with: + default_branch: ${{ github.event.repository.default_branch }} + is_pr: ${{ github.event_name == 'pull_request' }} + is_automated: ${{ github.actor == 'dependabot[bot]' }} + + dispatch_sdk_build: + needs: prerequisites + runs-on: ubuntu-latest + steps: + - name: Checkout central SDK repo + uses: actions/checkout@v4 + with: + repository: pulumi/pulumi-sdk + ref: main + path: pulumi-sdk + - name: Download bin + uses: ./.github/actions/download-bin + - name: Extract schema from plugin binary + run: | + mkdir -p pulumi-sdk/xyz + pulumi package get-schema ./bin/pulumi-resource-xyz > pulumi-sdk/xyz/schema.json + - name: Create PR (no linked issue) + uses: peter-evans/create-pull-request@v3.12.0 + id: cpr + with: + author: pulumi-bot + base: main + body: This pull request was generated automatically by the dispatch-build-sdk workflow in the xyz repository. + branch: pulumi-bot/publish-sdk-xyz-${{ github.run_id}} + commit-message: Publish SDKs for pulumi-xyz + committer: pulumi-bot + path: pulumi-sdk + labels: impact/no-changelog-required + title: Publish SDKs for pulumi-xyz version ${{ github.event.inputs.sdk_version }} + token: ${{ secrets.PULUMI_BOT_TOKEN }} + - name: Check outputs + run: | + echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" + echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" From 37579b47a39b07f1bae1816bb9b1a29b79fe00ed Mon Sep 17 00:00:00 2001 From: Ringo De Smet Date: Wed, 14 Aug 2024 12:25:38 +0200 Subject: [PATCH 2/5] Fix passing the version --- .github/workflows/dispatch_build_sdk.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/dispatch_build_sdk.yml b/.github/workflows/dispatch_build_sdk.yml index 444fd29a..55a3f27a 100644 --- a/.github/workflows/dispatch_build_sdk.yml +++ b/.github/workflows/dispatch_build_sdk.yml @@ -1,10 +1,6 @@ name: dispatch-build-sdk on: - workflow_dispatch: - inputs: - sdk_version: - description: 'SDK version to build' - required: true + workflow_dispatch: {} jobs: prerequisites: @@ -43,7 +39,7 @@ jobs: committer: pulumi-bot path: pulumi-sdk labels: impact/no-changelog-required - title: Publish SDKs for pulumi-xyz version ${{ github.event.inputs.sdk_version }} + title: Publish SDKs for pulumi-xyz version ${{ needs.prerequisites.outputs.version }} token: ${{ secrets.PULUMI_BOT_TOKEN }} - name: Check outputs run: | From d16077d92340ed077d3a675c74eda3de87cbf40d Mon Sep 17 00:00:00 2001 From: Daniel Bradley Date: Wed, 14 Aug 2024 14:51:00 +0200 Subject: [PATCH 3/5] Auto-run for PR --- .github/workflows/dispatch_build_sdk.yml | 87 ++++++++++++------------ 1 file changed, 45 insertions(+), 42 deletions(-) diff --git a/.github/workflows/dispatch_build_sdk.yml b/.github/workflows/dispatch_build_sdk.yml index 55a3f27a..6210a6bd 100644 --- a/.github/workflows/dispatch_build_sdk.yml +++ b/.github/workflows/dispatch_build_sdk.yml @@ -1,47 +1,50 @@ name: dispatch-build-sdk on: - workflow_dispatch: {} + workflow_dispatch: {} + pull_request: + branches: + - main jobs: - prerequisites: - uses: ./.github/workflows/prerequisites.yml - secrets: inherit - with: - default_branch: ${{ github.event.repository.default_branch }} - is_pr: ${{ github.event_name == 'pull_request' }} - is_automated: ${{ github.actor == 'dependabot[bot]' }} + prerequisites: + uses: ./.github/workflows/prerequisites.yml + secrets: inherit + with: + default_branch: ${{ github.event.repository.default_branch }} + is_pr: ${{ github.event_name == 'pull_request' }} + is_automated: ${{ github.actor == 'dependabot[bot]' }} - dispatch_sdk_build: - needs: prerequisites - runs-on: ubuntu-latest - steps: - - name: Checkout central SDK repo - uses: actions/checkout@v4 - with: - repository: pulumi/pulumi-sdk - ref: main - path: pulumi-sdk - - name: Download bin - uses: ./.github/actions/download-bin - - name: Extract schema from plugin binary - run: | - mkdir -p pulumi-sdk/xyz - pulumi package get-schema ./bin/pulumi-resource-xyz > pulumi-sdk/xyz/schema.json - - name: Create PR (no linked issue) - uses: peter-evans/create-pull-request@v3.12.0 - id: cpr - with: - author: pulumi-bot - base: main - body: This pull request was generated automatically by the dispatch-build-sdk workflow in the xyz repository. - branch: pulumi-bot/publish-sdk-xyz-${{ github.run_id}} - commit-message: Publish SDKs for pulumi-xyz - committer: pulumi-bot - path: pulumi-sdk - labels: impact/no-changelog-required - title: Publish SDKs for pulumi-xyz version ${{ needs.prerequisites.outputs.version }} - token: ${{ secrets.PULUMI_BOT_TOKEN }} - - name: Check outputs - run: | - echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" - echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" + dispatch_sdk_build: + needs: prerequisites + runs-on: ubuntu-latest + steps: + - name: Checkout central SDK repo + uses: actions/checkout@v4 + with: + repository: pulumi/pulumi-sdk + ref: main + path: pulumi-sdk + - name: Download bin + uses: ./.github/actions/download-bin + - name: Extract schema from plugin binary + run: | + mkdir -p pulumi-sdk/xyz + pulumi package get-schema ./bin/pulumi-resource-xyz > pulumi-sdk/xyz/schema.json + - name: Create PR (no linked issue) + uses: peter-evans/create-pull-request@v3.12.0 + id: cpr + with: + author: pulumi-bot + base: main + body: This pull request was generated automatically by the dispatch-build-sdk workflow in the xyz repository. + branch: pulumi-bot/publish-sdk-xyz-${{ github.run_id}} + commit-message: Publish SDKs for pulumi-xyz + committer: pulumi-bot + path: pulumi-sdk + labels: impact/no-changelog-required + title: Publish SDKs for pulumi-xyz version ${{ needs.prerequisites.outputs.version }} + token: ${{ secrets.PULUMI_BOT_TOKEN }} + - name: Check outputs + run: | + echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" + echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" From 0eeaa1d2296c0af2f2e78acbe2eb331dd6521797 Mon Sep 17 00:00:00 2001 From: Daniel Bradley Date: Wed, 14 Aug 2024 19:33:09 +0200 Subject: [PATCH 4/5] Add token for sdk checkout It's private, so we need to authenticate. --- .github/workflows/dispatch_build_sdk.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/dispatch_build_sdk.yml b/.github/workflows/dispatch_build_sdk.yml index 6210a6bd..ca4a2f91 100644 --- a/.github/workflows/dispatch_build_sdk.yml +++ b/.github/workflows/dispatch_build_sdk.yml @@ -24,6 +24,7 @@ jobs: repository: pulumi/pulumi-sdk ref: main path: pulumi-sdk + token: ${{ secrets.PULUMI_BOT_TOKEN }} - name: Download bin uses: ./.github/actions/download-bin - name: Extract schema from plugin binary From 69be9578d1d26b90e601a4fe57a74b17c4c646f0 Mon Sep 17 00:00:00 2001 From: Daniel Bradley Date: Wed, 14 Aug 2024 19:38:20 +0200 Subject: [PATCH 5/5] Check out source repo Otherwise we can't use the local download actions --- .github/workflows/dispatch_build_sdk.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/dispatch_build_sdk.yml b/.github/workflows/dispatch_build_sdk.yml index ca4a2f91..0bbdbd40 100644 --- a/.github/workflows/dispatch_build_sdk.yml +++ b/.github/workflows/dispatch_build_sdk.yml @@ -18,6 +18,8 @@ jobs: needs: prerequisites runs-on: ubuntu-latest steps: + - name: Checkout Repo + uses: actions/checkout@v4 - name: Checkout central SDK repo uses: actions/checkout@v4 with: