This GitHub action deploys the VTEX Toolbelt and can do log in using KEY/TOKEN. It can be useful to automate you CI/CD pipelines or just to schedules day-to-day tasks like cleaning dirty workspaces.
- Deploy VTEX Toolbelt (you can customize the repository/branch)
- Change the tool name, i.e. instead of
vtex
it can go byvtex-e2e
- Login using
app key
andapp token
- Cache resources to do the next deploy faster
- Check every step and stop if anything goes wrong
# toolbelt-workflow.yml
name: [QE] Deploy Toolbelt
on:
push:
branches:
- master
- main
workflow_dispatch:
jobs:
deploy:
name: Toolbelt deploy and login
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- name: Deploy toolbelt
uses: vtex/action-toolbelt@v8
If you want to log in, please, add two secrets on your repository secrets:
- One for the app key, in our example it is
VTEX_TOOLBELT_KEY
- Other for the token, in our example it is
VTEX_TOOLBELT_TOKEN
Next you need to set up your workflow like the example bellow, and that's it.
# toolbelt-workflow.yml
name: [QE] Deploy Toolbelt
on:
push:
branches:
- master
- main
workflow_dispatch:
jobs:
deploy:
name: Toolbelt deploy and login
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- name: Deploy toolbelt and login
uses: vtex/action-toolbelt@v8
with:
account: YOUR_ACCOUNT
appKey: ${{ secrets.VTEX_TOOLBELT_KEY }}
appToken: ${{ secrets.VTEX_TOOLBELT_TOKEN }}
authenticate: true # defaults to true, but it'll be false if
# any of account, appKey or appToken is missing
workspace: master # defaults to master
bin: vtex # defaults to vtex
version: 3.0.0-beta-ci.3 # defaults to 3.0.0-beta-ci.3
- name: Do something after the login
# The call name bellow must be the same given as *with: bin*
run: vtex workspace ls
- name: Logout
# The call name bellow must be the same given as *with: bin*
run: vtex logout
The output of this workflow will be something like that:
::notice title=Toolbelt version used::vtex/3.0.0 linux-x64 node-v16.13.0 [from https://github.com/vtex/toolbelt/tree/]
===> Fetching VTEX token... done.
===> Creating session.json... done.
===> Creating workspace.json... done.
===> Checking authentication... done.
14:01:15.234 - info: Logged into account as vtexkey-account-ABC at production workspace master
This action was made based on this issue discussion inspiration and I'll give my thanks to:
- rod-dot-codes for bridging the question and do a Python version of the script
- cantoniazzi for giving the direction to do it using only cURL
- achirus-code for making a version in Bash that inspired this action
Together we can do more!