-
-
Notifications
You must be signed in to change notification settings - Fork 157
64 lines (50 loc) · 1.95 KB
/
deploy-api.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
name: Build and Deploy API
on:
workflow_dispatch:
jobs:
build:
name: Build
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
node-version: [ 20.x ]
site_tlds: [ dev, org ]
steps:
- name: Checkout source code
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: |
cd mobile-api
npm ci --no-audit --no-progress --no-optional --no-shrinkwrap
- name: Build site
env:
NODE_ENV: production
run: npm run build:api
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v1
- name: Create a tagname
id: tagname
run: |
echo "tagname=$(git rev-parse --short HEAD)-$(date +%Y%m%d)-$(date +%H%M)" >> $GITHUB_ENV
- name: Build & Tag Images
run: |
cd mobile-api
docker build . \
--tag registry.digitalocean.com/${{ secrets.DOCR_NAME }}/${{ matrix.site_tlds }}/mobile-api:$tagname \
--tag registry.digitalocean.com/${{ secrets.DOCR_NAME }}/${{ matrix.site_tlds }}/mobile-api:latest \
--file Dockerfile
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Log in to DigitalOcean Container Registry with short-lived credentials
run: doctl registry login --expiry-seconds 1200
- name: Push image to DigitalOcean Container Registry
run: |
docker push registry.digitalocean.com/${{ secrets.DOCR_NAME }}/${{ matrix.site_tlds }}/mobile-api:$tagname
docker push registry.digitalocean.com/${{ secrets.DOCR_NAME }}/${{ matrix.site_tlds }}/mobile-api:latest