forked from facundoolano/google-play-api
-
Notifications
You must be signed in to change notification settings - Fork 0
134 lines (108 loc) · 3.58 KB
/
deploy.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
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Deploy Pipeline
on:
workflow_dispatch:
push:
branches: ["main", "dev"]
paths: ["!PostmanCollections/**", "!./github/**"]
pull_request:
branches: [ "dev" ]
jobs:
build_and_test:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Cache Node.js dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install Dependencies
run: npm install
- name: Generate OAS 3.0
run: npm run generateoas
- name: Start Server
run: npm start & npx wait-on http://localhost:3000
- name: Run Tests
run: npm test
- name: Upload HTML Report
uses: actions/[email protected]
with:
name: html-report
path: newman/*.html
build_and_push_docker_image:
needs: build_and_test
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log into GitHub Container Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile') }}
restore-keys: |
${{ runner.os }}-docker-
- name: Build and Push Docker Image
run: |
docker buildx create --use
docker buildx build --platform linux/amd64 -t ghcr.io/${{ github.repository }}:dev --push .
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
docker buildx build --platform linux/amd64 -t ghcr.io/${{ github.repository }}:main --push .
fi
docker buildx stop
deploy_to_fly:
needs: build_and_push_docker_image
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Get FlyCtl
uses: superfly/flyctl-actions/setup-flyctl@master
- name: Determine File Based on Branch
id: determine-env
run: |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
cp fly.production.toml fly.toml
echo "DEPLOY_TARGET=Fly" >> $GITHUB_ENV
else
cp fly.staging.toml fly.toml
echo "DEPLOY_TARGET=FlyDev" >> $GITHUB_ENV
fi
- name: start deployment
uses: bobheadxi/deployments@v1
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: ${{ env.DEPLOY_TARGET }}
- name: Deploy to Fly
run: flyctl deploy
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
- name: update deployment status
uses: bobheadxi/deployments@v1
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
env: ${{ steps.deployment.outputs.env }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
- name: Cache FlyCtl binary
uses: actions/cache@v3
with:
path: ~/.fly
key: ${{ runner.os }}-flyctl
restore-keys: |
${{ runner.os }}-flyctl-