-
Notifications
You must be signed in to change notification settings - Fork 1
59 lines (50 loc) · 1.79 KB
/
deploy.yml
File metadata and controls
59 lines (50 loc) · 1.79 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
name: Deploy backend to Heroku
on:
workflow_call:
secrets:
HEROKU_APP_NAME:
required: true
HEROKU_API_KEY:
required: true
jobs:
deploy:
runs-on: ubuntu-latest
env:
TEST_PIPELINE: "False"
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v3
with:
python-version: "3.12"
- name: Install Heroku CLI
run: curl https://cli-assets.heroku.com/install.sh | sh
- name: Authenticate with Heroku
run: |
echo "Authenticating with Heroku..."
echo "${{ secrets.HEROKU_API_KEY }}" | heroku auth:token
heroku auth:whoami
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
- name: Set up Heroku Git Remote
run: |
echo "Setting up Heroku remote..."
if ! git remote | grep -q "heroku"; then
git remote add heroku "https://git.heroku.com/${{ secrets.HEROKU_APP_NAME }}.git"
fi
git remote -v # Debugging: List remotes
- name: Push Backend to Heroku
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
run: |
echo "Setting up Git credentials..."
git config --global user.email "github-actions@github.com"
git config --global user.name "GitHub Actions"
echo "Setting up authentication..."
HEROKU_GIT_URL="https://heroku:$HEROKU_API_KEY@git.heroku.com/${{ secrets.HEROKU_APP_NAME }}.git"
git remote set-url heroku "$HEROKU_GIT_URL"
echo "Checking remotes..."
git remote -v # Debugging: Ensure the remote exists
echo "Forcing push to Heroku..."
git push --force heroku `git subtree split --prefix backend main`:main