Skip to content

Commit 99d98f2

Browse files
authored
[semver:minor] Allow CIRCLE_TAG to be used for deployments, fail if no tag or branch. (#8)
1 parent e12de66 commit 99d98f2

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/commands/deploy-via-git.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ parameters:
2424
type: string
2525
description: Deploy the given branch. The default value is your current branch.
2626
default: "$CIRCLE_BRANCH"
27+
tag:
28+
type: string
29+
description: Deploy the given tag. The default value is your current tag.
30+
default: "$CIRCLE_TAG"
2731
force:
2832
type: boolean
2933
description: Whether or not to force the git push (i.e. `git push -f`). Defaults to false.
@@ -42,12 +46,22 @@ steps:
4246
command: heroku maintenance:on --app << parameters.app-name >>
4347
- run:
4448
no_output_timeout: << parameters.no_output_timeout >>
45-
name: Deploy branch to Heroku via git push
49+
name: Deploy branch or tag to Heroku via git push
4650
command: |
4751
if << parameters.force >>;then
4852
force="-f"
4953
fi
50-
git push $force https://heroku:$<< parameters.api-key >>@git.heroku.com/<< parameters.app-name >>.git << parameters.branch >>:master
54+
55+
heroku_url = "https://heroku:$<< parameters.api-key >>@git.heroku.com/<< parameters.app-name >>.git"
56+
57+
if [ -z "<< parameters.branch >>" ]; then
58+
git push $force $heroku_url << parameters.branch >>:master
59+
elif [ -z "<< parameters.tag >>" ]; then
60+
git push $force $heroku_url << parameters.tag >>^{}:master
61+
else
62+
echo "No branch or tag found."
63+
exit 1
64+
fi
5165
- when:
5266
condition: << parameters.maintenance-mode >>
5367
steps:

src/jobs/deploy-via-git.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
description: >
2-
Quickly and easily take the changes to this branch and deploy them to Heroku automatically with this job.
2+
Quickly and easily take the changes to this branch or tag and deploy them to Heroku automatically with this job.
33
parameters:
44
app-name:
55
description:

0 commit comments

Comments
 (0)