@@ -13,29 +13,59 @@ jobs:
1313 contents : read
1414
1515 runs-on : ubuntu-latest
16+
17+ # ## Set variables for the given component.
18+ # ## See https://github.com/pulumi-pequod/pequod-policies/shared-github-actions/action.yml for the full list of supported inputs.
19+ env :
20+ # Need to manage the list of component types that this component repo provides.
21+ # FUTURE HOPE: Deduce this by parsing the component code or, better yet, be able to get this
22+ # via a Pulumi Cloud API after publishing.
23+ COMPONENT_TYPES : ' ["cloudfront-s3-cdk:index:CloudFrontS3"]'
24+ PULUMI_ORG : ' pequod' # The Pulumi organization to publish the component to.
1625
1726 steps :
1827 - name : Checkout repository
1928 uses : actions/checkout@v4
2029 with :
2130 ref : ${{ github.ref }} # Checkout the specific tag that triggered the workflow
2231 fetch-depth : 0 # Ensures the build matches the git tag.
23-
32+
2433 - name : Authenticate to Pulumi
2534 uses : pulumi/auth-actions@v1
2635 with :
27- organization : pequod
36+ organization : ${{ env.PULUMI_ORG }}
2837 requested-token-type : urn:pulumi:token-type:access_token:organization
38+ scope : admin
39+
40+ # Determine the version to use - either the triggered tag or latest tag for manual runs
41+ - name : Determine Component Version
42+ id : version
43+ run : |
44+ if [[ "${{ github.event_name }}" == "push" ]]; then
45+ # For tag pushes, use the tag that triggered the workflow
46+ VERSION="${{ github.ref_name }}"
47+ echo "Using triggered tag: $VERSION"
48+ else
49+ # For manual runs, get the latest tag
50+ VERSION=$(git tag --sort=-version:refname | head -1)
51+ echo "Manual run: Using latest tag: $VERSION"
52+ fi
53+ echo "version=$VERSION" >> $GITHUB_OUTPUT
2954
55+ # Publish if this is a tag push.
3056 - name : Publish Component to Pulumi Org
3157 if : github.event_name == 'push'
3258 run : |
33- echo "Publishing latest component version to the pequod Pulumi org."
34- pulumi package publish https://github.com/${{ github.repository }} --publisher pequod
59+ echo "Publishing latest component version to the ${{ env.PULUMI_ORG }} Pulumi org."
60+ pulumi package publish https://github.com/${{ github.repository }} --publisher ${{ env.PULUMI_ORG }}
61+
62+ # Update the policy config with the new component version regardless of if this is
63+ # a triggered or manual run.
64+ # Uses composite action in the pequod-policies repository to update the policy config.
65+ - name : Update Policy Config
66+ uses : pulumi-pequod/pequod-policies/shared-github-actions/component-version-policy-config@main
67+ with :
68+ pulumi_org : ${{ env.PULUMI_ORG }}
69+ component_types : ${{ env.COMPONENT_TYPES }}
70+ component_version : ${{ steps.version.outputs.version }}
3571
36- - name : Manual run - Skip publishing
37- if : github.event_name == 'workflow_dispatch'
38- run : |
39- echo "This is a manual workflow run."
40- echo "Skipping component publishing to prevent accidental releases."
41- echo "To publish, push a new tag instead of running manually."
0 commit comments