https://pulumi.com logo
#general
Title
# general
b

breezy-laptop-42679

06/11/2022, 2:40 PM
Can anyone please share a sample reusing github workflow file for pulumi preview?
c

clever-address-74879

06/11/2022, 6:22 PM
I usually just create an action and reuse that.
Copy code
name: Pulumi
description: Run Pulumi commands
inputs:
  azureClientId:
    required: true
  azureTenantId:
    required: true
  azureSubscriptionId:
    required: true
  pulumiStackName:
    required: true
  pulumiCommand:
    required: false
    default: preview
  pulumiWorkDir:
    required: false
    default: pulumi
  pulumiAccessToken:
    required: true

runs:
  using: "composite"
  steps:

    - uses: actions/setup-dotnet@v1
      with:
        dotnet-version: 6.0.x

    - name: az login
      uses: azure/login@v1
      with:
        client-id: ${{ inputs.azureClientId }}
        tenant-id: ${{ inputs.azureTenantId }}
        subscription-id: ${{ inputs.azureSubscriptionId }}

    - uses: pulumi/actions@v3
      with:
        command: ${{ inputs.pulumiCommand }}
        stack-name: ${{ inputs.pulumiStackName }}
        work-dir: ${{ inputs.pulumiWorkDir }}
      env:
        PULUMI_ACCESS_TOKEN: ${{ inputs.pulumiAccessToken }}
I then reuse it in different workflows eg. on pull requests I run this one
Copy code
name: Pulumi Preview

permissions:
  id-token: write
  contents: read

on:
  - pull_request
jobs:
  preview:
    name: Preview
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - uses: ./.github/actions/pulumi
        with:
          azureClientId: <client-id>
          azureTenantId: <tenant-id>
          azureSubscriptionId: <subscription-id>
          pulumiStackName: myorg/mystack
          pulumiCommand: preview
          pulumiWorkDir: ${{ github.workspace }}/pulumi
          pulumiAccessToken: ${{ secrets.PULUMI_ACCESS_TOKEN }}
In my case I use Azure for cloud and C# as language, but the Pulumi part is the same.
b

breezy-laptop-42679

06/11/2022, 6:29 PM
@clever-address-74879 thanks a lot. Cant thank enough would be using it for aws cloud any tips for me to be carefull on