Skip to content

Deploy to tmp-cre

Deploy to tmp-cre #63

---
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