canonical / action-build

A Github action for building Snapcraft projects
MIT License
42 stars 22 forks source link

action-build is no longer interpreting environment variables #79

Open Guillaumebeuzeboc opened 2 months ago

Guillaumebeuzeboc commented 2 months ago

The new release of action-build 1.3.0 appears to no longer import or use the environment variables of the GH step or job.

In my case:

    env:
      SNAPCRAFT_BUILDER_ID: ${{ github.run_id }}
    steps:
      [...]
      - uses: snapcore/action-build@v1
        env:
          SNAPCRAFT_REMOTE_BUILD_STRATEGY: force-fallback
        with:
          path: .
          snapcraft-args: "remote-build --launchpad-accept-public-upload --build-id ${{ matrix.snap_names }}-${{ SNAPCRAFT_BUILDER_ID }}"

to be interpreted as

/usr/bin/sudo -u runner -E snapcraft remote-build --launchpad-accept-public-upload --build-id noetic-desktop-amd64-${SNAPCRAFT_BUILDER_ID}

(SNAPCRAFT_BUILDER_ID is not interpreted)

Could be that this recent change induced the new behaviour

Our CI that was working fine before stopped working after this release.

Is it an intended behaviour?

jhenstridge commented 2 months ago

Your workflow is a bit different to the example you've given here (${{ SNAPCRAFT_BUILDER_ID }} vs. ${SNAPCRAFT_BUILDER_ID}).

The difference here is that we were previously calling snapcraft through sg, which interprets it's argument with the shell, and are now calling it through sudo which does not. You could work around this by changing the workflow to use ${{ env.SNAPCRAFT_BUILDER_ID }}, which will be expanded before the action is called.

With all that said, the snapcraft-args option has never been intended to be used to call arbitrary sub-commands like you're doing. If you want to call snapcraft remote-build, I'd suggest just doing that directly rather than using the action. You're not actually using any of the work the action does to allow regular snap builds to work within the Github runner.

Guillaumebeuzeboc commented 2 months ago

Sorry, indeed, I mixed up what I wanted to try and the actual situation. That is right, that we can directly call snapcraft remote-build in the workflow instead of using the action. We were use the action without the remote-build before, and didn't reconsider when adding the remote-build.