Deploy with tags

I’d like to add git tag in serverless, but not sure how to generate it on fly. I want to use it to follow up the deployment and rollback if required.

For example, I have the latest git tag 1.2.3 in my repository, and need use it to all environment/variable defined in the serviceless stack.

$ cat development.yml

stage: ${opt:stage, self:provider.stage}
service: serverless
tag: ${git describe --abbrev=0 --tags)    # <= how to make this works

Then I can use it as ${self:custom.tag} in serverless stack.

Did you ever figure this out?

I wrote a wrapper script before do the deployment. It doesn’t support in serverless framework currently.

I add my project repos to the CF description so I can hunt down stuff easier later

Demo: https://github.com/DavidWells/buslify/blob/master/api/serverless.yml#L65

Uses this script https://github.com/DavidWells/buslify/blob/master/api/scripts/git-remote.js

2 Likes

could you give details on how to put them together and make it work?

self:custom.repo calls this file and gives me the value https://github.com/DavidWells/buslify/blob/master/api/serverless.yml#L8

1 Like

Hi thanks for this script
I incorporated it as per your excellent example and added the
./scripts/git-remote.js

process.env.repo is still undefined for me
Any thoughts welcome

(it worked great as plain node code but NOT from serverless local custom var)

custom:
  repo: ${file(./scripts/git-remote.js):gitUrl}

Does this work with bitbucket cloud? @fearlessfly @DavidWells