-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
There is no way to automate the deployment via CI / CD because vtex login does not support token auth #1162
Comments
+1 |
@rod-dot-codes @simmbiote You can automate the log-in by Vtex API to generate the session token using your E.g
Then take a look at your local environment in the With the generated token you can create the JSON files with it and the other fields use environment variables from your repositories, such as the account name and the workspace name. Then you share this artifact ( I did this workaround and it works like a charm. 💅🏾 |
Awesome - thanks @cantoniazzi - I am going to try it out tonight! This is going to save us a lot of effort trying to keep our QA environments in sync. Will report back.. |
We implemented this in our store CI pipeline. |
+1 @cantoniazzi can you share some more infos? Did you build your own plugin to create these files by your own? Thanks a lot :) |
I wrote a mini bash. I hope it will help you guys.
|
I did something similar @TillmannD - but in Python, cause well, like my Bash ain't that strong. 🤖 I'm currently building some custom Github Actions for my team to automate deployments, I will share once done, and they are working without issues. I have to modify the Toolbelt due to the custom yes / no prompts for some of the commands. import requests
import os
import json
import pathlib
VTEX_ENV = os.environ.get('VTEX_ENVIRONMENT').lower()
VTEX_APP_KEY = os.environ.get('VTEX_APP_KEY')
VTEX_APP_TOKEN = os.environ.get("VTEX_APP_TOKEN")
response = requests.post(f"https://vtexid.vtex.com.br/api/vtexid/apptoken/login?an={VTEX_ENV}", json={'appkey': VTEX_APP_KEY, 'apptoken': VTEX_APP_TOKEN})
response.raise_for_status()
ROOT_DIRECTORY = pathlib.Path.home().joinpath(".vtex").joinpath("session")
os.makedirs(ROOT_DIRECTORY.as_posix())
print(ROOT_DIRECTORY.as_posix())
with open(ROOT_DIRECTORY.joinpath("session.json").as_posix(), "w+") as f:
main_session = response.json() | {"account": VTEX_ENV, "login": VTEX_APP_KEY}
json.dump(main_session, f, indent=4, sort_keys=True)
with open(ROOT_DIRECTORY.joinpath("token.json").as_posix(), "w+") as f:
json.dump(response.json(), f, indent=4, sort_keys=True)
with open(ROOT_DIRECTORY.joinpath("tokens.json").as_posix(), "w+") as f:
tokens = {VTEX_ENV: response.json()["token"]}
json.dump(tokens, f, indent=4, sort_keys=True)
with open(ROOT_DIRECTORY.joinpath("workspace.json").as_posix(), "w+") as f:
json.dump({"currentWorkspace": "master", "lastWorkspace": None}, f, indent=4, sort_keys=True)
print ("Login succeeded!") |
@rod-dot-codes Do you also needed to set the deployCli -> enabled to false in the cy-runner.yaml to get it work? |
guys, in GitLab I put the JSON's generated by the login as an artifact, that way I can share them between stages. |
some like that (ps: your runner needs
it's interesting let the variables ( with GitHub, I think you can upload/download the artifacts and reuse the token between vtex IO deploy flow (publish, deploy). https://github.com/actions/upload-artifact |
Hi @rod-dot-codes, @cantoniazzi, and @achirus-code, Today I reach this thread because we need to improve the login time on @achirus-code, even using the bash code you need to keep I'll start working to change the @rod-dot-codes, I'm really interested on this action. Do you need any help? It'll be awesome if this action:
What do you think? |
Just a warning here... all artifacts from public repositories are public on GitHub. So, take care 👀. |
Good point @thyarles. My repo's private. |
Hi there, I was so excited about this topic and the proposed solutions that I couldn't wait! With insights from this thread I was able to build the VTEX Toolbelt Action to deploy and login whatever you need using GitHub actions. This was an issue we've had on the US Team for Cypress tests since last year and we decided to address it this week. You guys give me a wonderful shortcut, thanks! BTW, the first version was published and it fully suits our needs. If you need something more, please, let me know. |
@thyarles I am super stoked to test this out! A big improvement - and this is the type of work VTEX should do to make our lives easier to roll this out! Great work! |
Hi @rod-dot-codes, thanks, I totally agree! Your code with the other ones here make it way easier... it needs a lot of fix to work for every pipeline, though. The improvement I want to make now is: instead of download a repository and build the customized You mention that you made some customization on the |
I will publish it this week, just been busy with first-month implementation issues on a new VTEX site - we are getting there but I am keen to share my versions to see if it makes it easier for us to grow this in the long term. |
Awesome, looking for it. If you need any help on that, count on me. |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
As a Software Engineer, I want to automate deployments to workspaces using Github Actions or Jenkins, but there is no supported login method besides the browser login route which does not work for automated processes.
This dramatically hinders our ability to do effective git flow - since manual steps have to be followed for each release.
Expected Behavior
I want to be able to login with a Private Access Token, even if we have to rotate this weekly and run a
vtex setup
andvtex link
headless for a workspace specified.Current Behavior
You can only login via the popup based browser flow which limits any modern CI / CD process that will allow us clean, consistent, repeatable deployments.
If this is on the roadmap, or there is a workaround - I would love to know.
The text was updated successfully, but these errors were encountered: