-
Notifications
You must be signed in to change notification settings - Fork 0
executable file
·65 lines (55 loc) · 2 KB
/
ci.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
65
name: CI
on:
push:
branches:
- main
env:
API_KEY: ${{ secrets.API_KEY }}
FIREBASE_PROJECT_ID: ${{ secrets.FIREBASE_PROJECT_ID }}
FIREBASE_PRIVATE_KEY: ${{ secrets.FIREBASE_PRIVATE_KEY }}
FIREBASE_CLIENT_EMAIL: ${{ secrets.FIREBASE_CLIENT_EMAIL }}
jobs:
build:
runs-on: ubuntu-latest
outputs:
branch_name: ${{ steps.branch-name.outputs.current_branch }}
steps:
- uses: actions/checkout@v2
- name: Docker Login
uses: docker/login-action@v1.10.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Branch Name
uses: tj-actions/branch-names@v5.1
id: branch-name
- name: Build and push
uses: docker/build-push-action@v2
with:
push: true
tags: ghcr.io/tobi2k/top-tips
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: SSH into server and pull image
uses: fifsky/ssh-action@master
with:
command: |
docker pull ghcr.io/tobi2k/top-tips
docker stop top-tips-server
docker rm top-tips-server
rm ./.env && touch ./.env
echo 'API_KEY=${{ secrets.API_KEY }}' >> ./.env
echo 'SENDGRID_API_KEY=${{ secrets.SENDGRID_API_KEY }}' >> ./.env
echo 'APP_VERSION=${{ secrets.APP_VERSION }}' >> ./.env
echo 'CRON=${{ secrets.CRON }}' >> ./.env
echo 'JWT_SECRET=${{ secrets.JWT_SECRET }}' >> ./.env
echo 'FIREBASE_PROJECT_ID=${{ secrets.FIREBASE_PROJECT_ID }}' >> ./.env
echo 'FIREBASE_PRIVATE_KEY=${{ secrets.FIREBASE_PRIVATE_KEY }}' >> ./.env
echo 'FIREBASE_CLIENT_EMAIL=${{ secrets.FIREBASE_CLIENT_EMAIL }}' >> ./.env
docker run -d --restart unless-stopped --network host --name=top-tips-server --env-file ./.env ghcr.io/tobi2k/top-tips
host: ${{ secrets.HOST }}
user: root
key: ${{ secrets.PRIVATE_KEY}}