balena-io / deploy-to-balena-action

Official Github action to deploy releases to balenaCloud environments
Apache License 2.0
38 stars 13 forks source link

Add deployment tests #244

Closed maggie44 closed 1 year ago

maggie44 commented 1 year ago

Adds a deploy to Cloud test to run after Flowzone completes.

The test:

maggie44 commented 1 year ago

@klutchell, it seems ${{ github.event.pull_request.head.sha }} isn't available inside the action.yml to specify a container. Here is an alternative way. Bit of a shame to have to have a test action.yml, would rather they used the same file but it's still pretty close.

Ideas welcome. Particularly on whether there is a better way to integrate the test into Flowzone rather than have it sitting below as an additional job (which works fine, but if there is a custom test option for Flowzone, may as well use it as intended).

klutchell commented 1 year ago

I was thinking part of your custom Flowzone action would be to use sed to replace the image string in the existing action.yml before running the action.

eg.

run: |
  sed -r 's|(image: docker://ghcr\.io/balena-io/deploy-to-balena-action:).+$|\1${{ github.event.pull_request.head.sha }} \
    -i action.yml
maggie44 commented 1 year ago

I think then it would need to commit that change to be able to access the action.yml file to be able to do the test deploy? Could have a look to see if we can reference a local action.yml without having to commit it, but was aiming to keep it as close to how it deploys normally.

klutchell commented 1 year ago

We definitely don't want to commit the change, you should be able to call a local action with uses: ./action.yml

eg. https://github.com/product-os/flowzone/blob/master/.github/workflows/tests.yml#L17

maggie44 commented 1 year ago

uses: ./action.yml

Didn't seem to like specifying the action.yml, but specifying the context ./ works ok, finding the action.yml as its default.

klutchell commented 1 year ago

uses: ./action.yml

Didn't seem to like specifying the action.yml, but specifying the context ./ works ok, finding the action.yml as its default.

Maybe using the full .yml path only works for reusable workflows. Either way, what you have seems to be correct!

klutchell commented 1 year ago

lgtm