Skip to content
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

Upload release with the API token #216

Open
littlewall opened this issue Mar 24, 2021 · 7 comments · Fixed by #225
Open

Upload release with the API token #216

littlewall opened this issue Mar 24, 2021 · 7 comments · Fixed by #225

Comments

@littlewall
Copy link

Hello,
If I get it right, to upload the release through the API endpoint POST /api/v1/sites/:siteId:/releases, I have to provide a site token instead of an API token (even with the enabled release.upload scope). Is that a purpose?

Why I'm asking - in custom Github Action, if I want to handle both uploading and removing releases, I have to set both tokens (site token and API token). It would be more convenient to use only the API token for both operations.

Thanks for the consideration,
Milan Zítka

@gempain
Copy link
Contributor

gempain commented Mar 24, 2021

Hi Mikan, and thanks for asking ! This is correct, uploading a site happens with the API and deleting a release requires an API token. This has been discussed in #167. What we're thinking about is to add a delete command to the CLI and allow using the delete endpoint with a site token, while preventing the deletion of the main branch. This should solve your problem.

@gempain gempain added the feature New feature label Mar 24, 2021
@littlewall
Copy link
Author

Thank you for your quick reply :)

Well, yes and no. Yes, it would somehow resolve my problem with different tokens for upload/delete release.

But in my specific case, a more versatile solution would be to enable release upload with API token (so this endpoint would accept both API and site token)

More specifically, a site token would not be required if a valid API token with enabled release.upload scope is present). I'm doing all the work inside the nodejs script, so it's much easier to use API calls than to run bash commands with Meli CLI.

I think those who want to be safer would use CLI with a site token. Who knows exactly what he's doing will create an API token with needed scopes enabled.

If it can't be done this way (for any security or other reason), I'm ok with it, just asking :) But in that case, the option to enable this scope for API token is irrelevant and should be removed from UI as it is confusing at this time (you can enable release.upload scope, but you can't really call that endpoint with this token).
image

@gempain
Copy link
Contributor

gempain commented Mar 26, 2021

For sure ! We'll add a scope for this endpoint so you can use it with the API as well. What would be really cool if that you share your script with us when you're done with it. We (or you, if interested) could write a Github actions with this so people can just specify their token, siteId, url etc and it would handle both upload and delete for PRs while keeping the main branch active.

That said, for safety reasons, we would probably by default prevent someone from deleting the main branch of a site via the API, and you could disable this behavior from your site settings.

@littlewall
Copy link
Author

littlewall commented Mar 29, 2021

Ok, that sounds good :) Thank you for your great work!

Yes, actually, I need it for our company's Github Action, so once the changes are done, and Action will be ready, I will be happy to share it with the community. Even if we need it primarily for branch previews (not only on PR but also for any branch create and push), I'll try to make this Action as universal as possible. Also, I'll prepare Github Action workflows examples for various scenarios.

@littlewall
Copy link
Author

We made our first try of Github Action:
https://github.com/digitalvisioncz/meli-deploy-github-action

@gempain
Copy link
Contributor

gempain commented Apr 12, 2021

@littlewall wow ! This is amazing ! I'll work on this issue early this week and release by the end of the week.

I've noticed that you rewrote some logic that we have in our CLI. We'll update our CLI to expose methods for using it inside JS. This might make it easier for you.

gempain added a commit that referenced this issue Apr 13, 2021
Co-authored-by: Geoffroy Empain <geoffroy@charlie-bravo.be>
gempain pushed a commit that referenced this issue May 21, 2021
# [1.0.0-beta.23](v1.0.0-beta.22...v1.0.0-beta.23) (2021-05-21)

### Bug Fixes

* cannot upload or delete logo (closes [#230](#230)) ([970e1f4](970e1f4))
* incorrect description and missing info in package.json ([#227](#227)) ([290de80](290de80))
* wrong site / branch url in ui ([d33f03f](d33f03f))

### Features

* allow deleting branches with site token ([b107ed7](b107ed7))
* update DomainForm with private key help text ([#231](#231)) ([da4562d](da4562d))
* upload release with api token ([#216](#216)) ([#225](#225)) ([1d5ceb6](1d5ceb6))
@meli-release-bot
Copy link
Collaborator

🎉 This issue has been resolved in version 1.0.0-beta.23 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants