-
Notifications
You must be signed in to change notification settings - Fork 11
92 lines (76 loc) · 2.64 KB
/
deploy.yml
File metadata and controls
92 lines (76 loc) · 2.64 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: Deploy
on:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
HEROKU_STAGING_APP_NAME: batnoter-staging
HEROKU_PRODUCTION_APP_NAME: batnoter
jobs:
build:
runs-on: ubuntu-latest
env:
GITHUB_REPO_REGISTRY: ghcr.io/${{ github.repository_owner }}/batnoter
steps:
- uses: actions/checkout@v2
- name: build docker image
env:
COMMIT_SHA: ${{ github.sha }}
HEROKU_PROCESS_TYPE: web
run: |
docker build \
-t registry.heroku.com/$HEROKU_STAGING_APP_NAME/$HEROKU_PROCESS_TYPE \
-t registry.heroku.com/$HEROKU_PRODUCTION_APP_NAME/$HEROKU_PROCESS_TYPE \
-t $GITHUB_REPO_REGISTRY/${GITHUB_REPOSITORY#*/}:${GITHUB_REF##*/} \
-t $GITHUB_REPO_REGISTRY/${GITHUB_REPOSITORY#*/}:$COMMIT_SHA \
-t $GITHUB_REPO_REGISTRY/${GITHUB_REPOSITORY#*/}:latest .
- name: login to github docker registry
uses: docker/login-action@v1.14.1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: publish docker image to github registry
run: |
docker push -a $GITHUB_REPO_REGISTRY/${GITHUB_REPOSITORY#*/}
- name: login to heroku docker registry
uses: docker/login-action@v1.14.1
with:
registry: registry.heroku.com
username: ${{ github.repository_owner }}
password: ${{ secrets.HEROKU_API_KEY }}
- name: publish docker image to heroku registry
env:
HEROKU_PROCESS_TYPE: web
run: |
docker push -a registry.heroku.com/$HEROKU_STAGING_APP_NAME/$HEROKU_PROCESS_TYPE
docker push -a registry.heroku.com/$HEROKU_PRODUCTION_APP_NAME/$HEROKU_PROCESS_TYPE
deploy-staging:
needs: [build]
runs-on: ubuntu-latest
environment:
name: Staging
url: 'https://batnoter-staging.herokuapp.com/'
steps:
- name: publish to staging on heroku
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
run: |
heroku container:release web -a $HEROKU_STAGING_APP_NAME
heroku releases --json -n 1 -a $HEROKU_STAGING_APP_NAME | grep '"succeeded"'
deploy-production:
needs: [deploy-staging]
runs-on: ubuntu-latest
environment:
name: Production
url: 'https://batnoter.herokuapp.com/'
steps:
- name: publish to production on heroku
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
run: |
heroku container:release web -a $HEROKU_PRODUCTION_APP_NAME
heroku releases --json -n 1 -a $HEROKU_PRODUCTION_APP_NAME | grep '"succeeded"'