jonbio/.gitea/workflows/build.yml

82 lines
2.8 KiB
YAML
Raw Normal View History

2024-10-20 00:45:46 -05:00
name: Build and Deploy docker container
2024-11-04 23:18:28 -06:00
'on':
2024-10-17 13:23:20 -05:00
push:
branches: main
jobs:
build:
runs-on: ubuntu-latest
steps:
2024-11-19 14:50:18 -06:00
# - name: Send message job is starting
# uses: cstuder/apprise-ga@master
# with:
# title: 'jonb.io site deployment'
# message: >-
# Started build for:
# Commit by {{ head_commit.author.name }}: {{ head_commit.message |
# truncate(128) }} ({{ head_commit.id[0:7] }})
# env:
# APPRISE_URL: '${{ secrets.APPRISE_URL }}'
2024-11-15 14:52:06 -06:00
- name: Checkout main
uses: actions/checkout@v4
2024-11-02 23:49:20 -05:00
- name: Install Yarn
run: npm install -g yarn
- name: Set Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 22.x
2024-11-04 23:18:28 -06:00
cache: yarn
2024-11-02 23:49:20 -05:00
- name: Get yarn cache directory path
id: yarn-cache-dir-path
2024-11-02 23:50:29 -05:00
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
2024-11-15 14:52:06 -06:00
- name: Restore cache
uses: actions/cache@v4
2024-11-04 23:18:28 -06:00
id: yarn-cache
2024-11-02 23:49:20 -05:00
with:
2024-11-02 23:55:42 -05:00
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
2024-11-19 14:50:18 -06:00
${{ github.workspace }}/.next/
2024-11-20 23:20:04 -06:00
node_modules/
${{ github.workspace }}/out/
2024-11-04 23:18:28 -06:00
key: '${{ runner.os }}-yarn-${{ hashFiles(''**/yarn.lock'') }}'
2024-11-02 23:49:20 -05:00
restore-keys: |
${{ runner.os }}-yarn-
2024-11-15 14:52:06 -06:00
- name: Update node modules
2024-11-15 22:48:01 -06:00
run: yarn install --immutable
2024-11-15 17:24:47 -06:00
- name: Lint
run: yarn lint
2024-11-15 14:52:06 -06:00
- name: Build app and export to ./out
2024-11-19 14:57:11 -06:00
run: EXPORT=1 UNOPTIMIZED=1 yarn build
2024-11-04 23:18:28 -06:00
- name: Set up Docker Buildx
2024-11-02 23:49:20 -05:00
uses: docker/setup-buildx-action@v3
2024-11-04 23:18:28 -06:00
- name: Login to Docker Hub
2024-11-02 23:49:20 -05:00
uses: docker/login-action@v3
with:
registry: git.jonb.io
2024-11-04 23:18:28 -06:00
username: '${{ gitea.actor }}'
password: '${{ secrets.JONBIO_CI }}'
- name: Build and push
2024-11-02 23:49:20 -05:00
uses: docker/build-push-action@v6
with:
context: .
push: true
2024-11-04 23:18:28 -06:00
tags: 'git.jonb.io/jblu/jonbio:latest'
cache-from: 'type=registry,ref=git.jonb.io/jblu/jonbio:buildcache'
cache-to: >-
type=registry,image-manifest=true,oci-mediatypes=true,ref=git.jonb.io/jblu/jonbio:buildcache,mode=max
2024-11-15 22:48:01 -06:00
- name: Deploy app
2024-11-02 23:49:20 -05:00
uses: fjogeleit/http-request-action@v1
with:
url: 'http://192.168.4.11:7777/v1/update'
2024-11-04 23:18:28 -06:00
method: GET
bearerToken: '${{ secrets.DEPLOYTOKEN }}'
timeout: 60000
2024-11-15 14:52:06 -06:00
- name: Send message app has deployed
uses: cstuder/apprise-ga@master
2024-11-04 23:18:28 -06:00
with:
2024-11-04 23:18:39 -06:00
title: 'jonb.io site deployment'
2024-11-04 23:20:20 -06:00
message: >-
2024-11-15 14:52:06 -06:00
Deployed {{head_commit.message}}
2024-11-04 23:20:20 -06:00
Commit by {{ head_commit.author.name }}: {{ head_commit.message |
2024-11-15 14:52:06 -06:00
truncate(128) }} ({{ head_commit.id[0:7] }})
2024-11-04 23:18:28 -06:00
env:
APPRISE_URL: '${{ secrets.APPRISE_URL }}'