`pulumi-version-file` only works in install-only mode
What happened?
It seems that the pulumi-version-file input argument only works in install-only mode. I do not think this is expected behavior according to the documentation in the readme or in the PR: https://github.com/pulumi/actions/pull/1204
When in non-install-only mode
When running the following action config:
- name: Preview <project-name> changes
uses: pulumi/actions@v5
env:
PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }}
with:
command: preview
work-dir: ./projects/<project>
comment-on-pr: true
stack-name: prod
pulumi-version-file: ./.pulumi.version
cloud-url: ${{ steps.backend-url.outputs.result }}
I get this output:
> Run pulumi/actions@v5
Configured range:
Matched version: v3.121.0
Install destination is /home/ubuntu/.pulumi
Successfully deleted pre-existing /home/ubuntu/.pulumi/bin
/usr/bin/tar xz --warning=no-unknown-keyword --overwrite -C /home/ubuntu/.pulumi -f /opt/actions-runner/_work/_temp/6800d063-e7de-41b2-86b5-d307745b54ce
Logging into s3://<i-removed-this>
pulumi preview on prod
Just to test, the content of the .pulumi.version file is:
3.120.0
When in install-only mode
- name: Install Pulumi
uses: pulumi/actions@v5
with:
pulumi-version-file: ./.pulumi.version
- name: Preview <project-name> changes
uses: pulumi/actions@v5
env:
PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }}
with:
command: preview
work-dir: ./projects/<project>
comment-on-pr: true
stack-name: prod
pulumi-version-file: ./.pulumi.version
cloud-url: ${{ steps.backend-url.outputs.result }}
Output:
# Install Pulumi
> Run pulumi/actions@v5
Configured range: 3.120.0
Matched version: v3.120.0
Install destination is /home/ubuntu/.pulumi
Successfully deleted pre-existing /home/ubuntu/.pulumi/bin
/usr/bin/tar xz --warning=no-unknown-keyword --overwrite -C /home/ubuntu/.pulumi -f /opt/actions-runner/_work/_temp/3cadc875-d728-485a-b0d5-18bd5df5536d
Pulumi has been successfully installed. Exiting.
# Preview <project-name> changes
> Run pulumi/actions@v5
Configured range:
/opt/actions-runner/_work/_tool/pulumi/3.120.0/x64/pulumi version
v3.120.0
Pulumi version 3.120.0 has a known issue. Proceeding to download
Matched version: v3.121.0
Install destination is /home/ubuntu/.pulumi
Successfully deleted pre-existing /home/ubuntu/.pulumi/bin
/usr/bin/tar xz --warning=no-unknown-keyword --overwrite -C /home/ubuntu/.pulumi -f /opt/actions-runner/_work/_temp/1ea31476-34e3-48d1-874b-89a2915cc197
Logging into s3://<i-removed-this>
pulumi preview on prod
Example
The example comes from a GHES repo, but the following does not work:
When running the following action config:
- name: Preview <project-name> changes
uses: pulumi/actions@v5
env:
PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }}
with:
command: preview
work-dir: ./projects/<project>
comment-on-pr: true
stack-name: prod
pulumi-version-file: ./.pulumi.version
cloud-url: ${{ steps.backend-url.outputs.result }}
I get this output:
> Run pulumi/actions@v5
Configured range:
Matched version: v3.121.0
Install destination is /home/ubuntu/.pulumi
Successfully deleted pre-existing /home/ubuntu/.pulumi/bin
/usr/bin/tar xz --warning=no-unknown-keyword --overwrite -C /home/ubuntu/.pulumi -f /opt/actions-runner/_work/_temp/6800d063-e7de-41b2-86b5-d307745b54ce
Logging into s3://<i-removed-this>
pulumi preview on prod
Just to test, the content of the .pulumi.version file is:
3.120.0
Output of pulumi about
CLI
Version 3.121.0
Go Version go1.22.4
Go Compiler gc
Plugins
KIND NAME VERSION
resource aws 6.42.0
language nodejs unknown
resource tls 5.0.3
Host
OS ubuntu
Version 22.04
Arch x86_64
This project is written in nodejs: executable='/home/<user>/.nvm/versions/node/v18.20.3/bin/node' version='v18.20.3'
Backend
Name <computer-name>
URL s3://<s3-bucket>
User <user>
Organizations
Token type personal
Additional context
In the config.ts file pulumi-version-file input is only read in makeInstallationConfig:
https://github.com/pulumi/actions/blob/760956aff50b515c197ee22d30aa8d756f7b86a2/src/config.ts#L27
installationConfig is only valid when command is undefined, so in main.ts the if statement checking downloadConfig.success is skipped when not in install-only mode:
https://github.com/pulumi/actions/blob/760956aff50b515c197ee22d30aa8d756f7b86a2/src/main.ts#L23-L28
So, when not in install-only mode, then full config does not use pulumi-version-file. Also, I suspect getInput('pulumi-version') returns an empty string causing pulumiVersion to be an empty string, rather than ^3 (I'm thinking this because of the outputted line Configured range: which should end with the value from pulumiVersion).
https://github.com/pulumi/actions/blob/760956aff50b515c197ee22d30aa8d756f7b86a2/src/main.ts#L32-L34
https://github.com/pulumi/actions/blob/760956aff50b515c197ee22d30aa8d756f7b86a2/src/main.ts#L43-L44
Contributing
Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).
Thanks for opening the issue!
This issue has been addressed in PR #1218 and shipped in release v5.3.3.