Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.

Commit b8fadac

Browse files
committed
fix: deploy
1 parent ebad27d commit b8fadac

3 files changed

Lines changed: 68 additions & 26 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,33 @@
11
name: Deploy to Caprover
22
permissions: read-all
33
on:
4-
push:
5-
branches: main
4+
registry_package:
5+
types: [published]
66

77
jobs:
8-
build:
8+
build-and-deploy:
99
runs-on: ubuntu-latest
1010

1111
strategy:
1212
matrix:
1313
node-version: [18.x]
1414

1515
steps:
16-
- name: Check out repository
17-
uses: actions/checkout@v4
18-
- name: Use Node.js ${{ matrix.node-version }}
19-
uses: actions/setup-node@v3
20-
with:
21-
node-version: ${{ matrix.node-version }}
22-
cache: 'npm'
23-
- run: npm ci
24-
- run: npm run build --if-present
25-
26-
- uses: a7ul/tar-action@v1.1.0
27-
with:
28-
command: c
29-
cwd: './'
30-
files: |
31-
dist/
32-
captain-definition
33-
outPath: deploy.tar
34-
35-
- name: Deploy to CapRrover
16+
- name: Deploy Image to CapRrover
3617
uses: caprover/deploy-from-github@v1.1.2
3718
with:
3819
server: '${{ secrets.CAPROVER_SERVER }}'
3920
app: trending
4021
token: '${{ secrets.CAPROVER_TOKEN }}'
22+
image: ghcr.io/eddiehubcommunity/trending:latest
4123

4224
migrations:
43-
needs: build
4425
runs-on: ubuntu-latest
4526
steps:
4627
- uses: actions/checkout@v4
4728
- uses: actions/setup-node@v4
4829
with:
49-
node-version: ${{ matrix.node-version }}
30+
node-version: 22.4
5031
- name: install dependencies
5132
run: npm ci
5233
- name: run migrations

.github/workflows/docker.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Publish Docker
2+
permissions: read-all
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: npm install and build
13+
run: |
14+
npm ci
15+
echo "DATABASE_URL=${{ secrets.DATABASE_URL }}" >> .env
16+
npm run build
17+
- name: Save .env as artifact
18+
uses: actions/upload-artifact@v4
19+
with:
20+
name: env-file
21+
path: .env
22+
- uses: actions/upload-artifact@v4
23+
with:
24+
name: artifacts
25+
path: prod/
26+
27+
push_to_registry:
28+
name: Push Docker image to GitHub Packages
29+
needs: build
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: check out the repo
33+
uses: actions/checkout@v4
34+
# - name: Download .env artifact
35+
# uses: actions/download-artifact@v4
36+
# with:
37+
# name: env-file
38+
# path: .
39+
- name: npm install
40+
run: |
41+
npm ci
42+
echo "DATABASE_URL=${{ secrets.DATABASE_URL }}" >> .env
43+
- name: get-npm-version
44+
id: package-version
45+
uses: martinbeentjes/npm-get-version-action@master
46+
- name: version dockerfile
47+
uses: docker/setup-buildx-action@v3
48+
- name: log into GitHub Container Registry
49+
uses: docker/login-action@v3
50+
with:
51+
registry: ghcr.io
52+
username: ${{ github.repository_owner }}
53+
password: ${{ secrets.CR_PAT }}
54+
- name: push to Github Container Registry
55+
uses: docker/build-push-action@v6
56+
with:
57+
context: .
58+
push: true
59+
tags: |
60+
ghcr.io/eddiejaoude/trending:v${{ steps.package-version.outputs.current-version }}
61+
ghcr.io/eddiejaoude/trending:latest

captain-definition

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"schemaVersion": 2,
3-
"dockerfilePath": "./Dockerfile"
3+
"imageName": "ghcr.io/eddiehubcommunity/trending:latest"
44
}

0 commit comments

Comments
 (0)