clever-tools
clever-tools copied to clipboard
Add `--tag` option to `clever deploy`
Right now, with the new isomorphic-git based clever-tools, we cannot deploy a tag. We have identified why isomorphic-git cannot do it (for now), filed an issue and proposed a solution.
When this is available, we'll be able to add an option to clever deploy called --tag to push and deploy a specific tag to the clever remote.
Up ! Some news about this feature ? Because I'm trying to deploy from a tag through GitLab CI and it seems to not working :(
Hello @simon-tannai,
Right now, you can checkout the tag and then clever deploy.
Thanks @urcadox for your reply !
So, I'm using $CI_COMMIT_REF_NAME Gitlab's variable who contains the name of the branch / tag. The first echo in my Gitlab CI script above displaying well the name of my tag:
cd ./dist
cp -r ./../.git ./
echo -e "\n\nGit tag is $CI_COMMIT_REF_NAME\n\n"
git checkout $CI_COMMIT_REF_NAME
echo "Sources:"
ls -al
echo -e "\n\n"
echo "Installing clever-tools ..."
npm i clever-tools
echo "clever-tools installed"
echo "Logging to Clever Cloud with token ..."
./node_modules/clever-tools/bin/clever.js login --token $CC_TOKEN_DEV --secret $CC_SECRET_DEV
echo "Logged"
echo "Linking to app ..."
./node_modules/clever-tools/bin/clever.js link $APP_ID_BOT_DEV
echo "Deploying ..."
./node_modules/clever-tools/bin/clever.js deploy --verbose --branch $CI_COMMIT_REF_NAME --force
I got this error:
[ERROR] Object 3d36ef0b98af39d9a6258b8025ffbeb3a895c31d was anticipated to be a commit but it is a tag. This is probably a bug deep in isomorphic-git!
Oh. That's weird.
Can you try using the latest beta of clever-tools (which uses a more recent version of isomorphic-git)?
@urcadox I got the same issue with npm i [email protected]
Alright then, I'm out of ideas. Let's wait for the input from @hsablonniere.
Sadly, I think we need to wait for isomorphic-git.
@simon-tannai
- Can you you tell us the content of
$CI_COMMIT_REF_NAME? I'm not expecting the real sha1, I juste want to know if it's a sha1 or a ref... - I think the manual
git checkouthelps but if you do that, you don't need the--brancharg.
@haitlahcen the default variable $CI_COMMIT_REF_NAME contains the name of the branch or tag (https://docs.gitlab.com/ee/ci/variables/predefined_variables.html) In my case, the name of the tag is test-1.
I tried without --branch, I got the same error.
I also tried to checkout on new branch from my tag but files are not tracked:
HEAD is now at 63f71f4... Update CI
D .gitignore
D .gitlab-ci.yml
D CHANGELOG.md
D README.md
...
Untracked files:
(use "git add <file>..." to include in what will be committed)
package-lock.json
package.json
That's why I got the error Error: a package.json file is mandatory, containing the node version, the entry point ("main" category) and, if needed, the dependencies. when I'm checking out on the tag.
For the moment, the only method to work well with Gitlab CI and tag is to deploy through Git:
git init
git remote add clever https://$DEV_CC_TOKEN:$DEV_CC_SECRET@push-par-clevercloud-customers.services.clever-cloud.com/$DEV_CC_APP_ID_BOT.git
git config --global user.email "YOUR_EMAIL"
git config --global user.name "Simon Tannai"
git add -A
git commit -m "Deploy"
git push clever master --force
Note that I'm working with an artifact, built in a previous job and not commited.
We just tested this with @aurrelhebert and clever deploy --branch TAG_NAME works.
We'll introduce a new option named --tag which first checks that the tag is actually a tag locally and then pushes it
Like others users I want to deploy on my production environments only specific releases / tags.
I tried something like clever deploy --alias "staging" --branch "v2.7.0" but it fails because it tries to send again the tag and the remote refuses it.
I quickly reviewed #599 and it seems to fix the issue by checking if the tag exists and by sending the tag by its SHA1.