-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (46 loc) · 1.62 KB
/
cicd.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
name: CI/CD
on:
push:
branches:
- deploy
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Use Node.js
run: |
touch .env.prod
echo APP_HOST=${{ env.APP_HOST }} >> .env.prod
echo DATABASE_HOST=${{ env.DATABASE_HOST }} >> .env.prod
echo DATABASE_PORT=${{ env.DATABASE_PORT }} >> .env.prod
echo TOKEN_SECRET="${{ secrets.TOKEN_SECRET }}" >> .env.prod
echo CRYPTO_KEY="${{ secrets.CRYPTO_KEY }}" >> .env.prod
cat .env.prod
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '22.x'
- name: Install frontend dependencies
run: npm ci
- name: Build frontend
run: npm run prod
- name: Login to DockerHub
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
- name: Build docker
run: docker build . -t dorianneto/burn-secret-web -f ./.docker/go/Dockerfile --platform linux/amd64
- name: Push docker
run: docker push dorianneto/burn-secret-web:latest
deploy:
runs-on: self-hosted
needs: build
steps:
- name: Pull docker image
run: docker pull dorianneto/burn-secret-web:latest
- name: Remove current container
run: docker rm -f burn-secret-web-container
- name: Remove old images
run: docker rmi $(docker images --filter "dangling=true" -q --no-trunc)
- name: Runs container
run: docker run -d -p 80:80 -e APP_ENV=prod --name burn-secret-web-container dorianneto/burn-secret-web