Shopify/lighthouse-ci-action

How to get preview url, editor url and themeid from one step to another

alexantom opened this issue · 4 comments

I would like to output preview url, editor URL and themeid so that it can be accessed in next steps. Is this something possible now or do we need to add below scripts.

entrypoint.sh

preview_url="$(cat "$theme_push_log" | tail -n 1 | jq -r '.theme.preview_url')"
editor_url="$(cat "$theme_push_log" | tail -n 1 | jq -r '.theme.editor_url')"
theme_id="$(cat "$theme_push_log" | tail -n 1 | jq -r '.theme.id')"
echo "::set-output name=preview_url::$preview_url"
echo "::set-output name=editor_url::$editor_url"
echo "::set-output name=theme_id::$theme_id"

ci.yml

- name: Lighthouse
        id: lighthouse
        uses: shopify/lighthouse-ci-action@1.0
        with:
          app_id: ${{ secrets.SHOP_APP_ID }}
          app_password: ${{ secrets.SHOP_APP_PASSWORD }}
          store:${{ secrets.SHOP}}
          password: ${{ secrets.SHOP_PASSWORD }}
- name: Print Deploy Output
        run: |
          echo "::Preview Url:: ${{steps.lighthouse.outputs.preview_url}}"
          echo "::Editor Url:: ${{steps.lighthouse.outputs.editor_url}}"
          echo "::Theme ID:: ${{steps.lighthouse.outputs.theme_id}}"

Changes can be found here

alexantom@a4a7467

We don't output them now. But maybe we should!

Also IIRC, it's good practice to declare your outputs in the actions.yml output field.

But I'm not sure that works if we delete the theme after.

https://github.com/Shopify/lighthouse-ci-action/blob/main/entrypoint.sh#L89

@charlespwd i missed the cleanup job :), i was trying to reuse this action to create feature branch based environment for testing.

I couldn't see the logs associated with cleanup job here
https://github.com/Shopify/lighthouse-ci-action/runs/4048646600?check_suite_focus=true

That's a good idea. All you really need is this part here:

https://github.com/Shopify/lighthouse-ci-action/blob/main/entrypoint.sh#L118-L144

IIRC development themes get cleaned up after two weeks of inactivity.

You might be even be able to pipe the output of that into https://github.com/shopify/github-deployment-action to get a GitHub environment for it.