-
Notifications
You must be signed in to change notification settings - Fork 34
43 lines (42 loc) · 1.53 KB
/
deploy-staging.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
---
name: "Deploy to tmp-cre"
on:
workflow_dispatch: # allow manual triggering
workflow_run:
workflows: ["Test-e2e","Lint Code Base","Test"]
types:
- completed
branches:
- staging
jobs:
deploy:
environment: tmp-cre
name: deploy
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: staging
- name: Deploy backend to heroku
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
HEROKU_APP_NAME: tmp-cre
run: |
git config user.name spyros
git config user.email "[email protected]" # git just needs AN email, it doesn't matter which
# git fetch --all --unshallow --tags
highest_tag="$(git tag -l --sort=-v:refname | grep ^v | sed 1q)"
echo "highest tag is ${highest_tag}"
echo "autodeployment only supports minor tags"
git remote add heroku https://heroku:${{ secrets.HEROKU_API_KEY }}@git.heroku.com/tmp-cre.git
commit_sha=$(git rev-parse origin/main)
major=$(echo "${highest_tag}" | cut -f1 -d. | tr -dc '0-9')
minor=$(echo "${highest_tag}" | cut -f2 -d. | tr -dc '0-9')
patch=$(echo "${highest_tag}" | cut -f3 -d. | tr -dc '0-9')
patch=$((patch+1))
new_tag="v${major}.${minor}.${patch}"
echo "new tag is ${new_tag}"
git tag --annotate "${new_tag}" --message "${new_tag}" "${commit_sha}"
git push --force heroku staging:main --follow-tags