-
Notifications
You must be signed in to change notification settings - Fork 33
42 lines (41 loc) · 1.51 KB
/
deploy.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
---
name: "Deploy to OPENCREORG"
on:
workflow_dispatch: # allow manual triggering
workflow_run:
workflows: ["Test-e2e","Lint Code Base","Test"]
types:
- completed
branches:
- main
jobs:
deploy:
environment: opencreorg
name: deploy
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Deploy backend to heroku
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
HEROKU_APP_NAME: opencreorg
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/opencreorg.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 main --follow-tags