70 lines
2.4 KiB
YAML
70 lines
2.4 KiB
YAML
on:
|
|
push:
|
|
branches:
|
|
- "**"
|
|
tags:
|
|
- "v*.*.*"
|
|
pull_request:
|
|
env:
|
|
# Image name
|
|
image: l4d2-stats-plugin
|
|
tag: ${{ forgejo.ref_name }}
|
|
user: deploy
|
|
registry: git.jackz.me
|
|
|
|
jobs:
|
|
build:
|
|
name: Build Website
|
|
runs-on: ubuntu-full
|
|
env:
|
|
# App envs
|
|
PUBLIC_SITE_URL: ${{ vars.PUBLIC_SITE_URL }}
|
|
PUBLIC_SITE_NAME: ${{ vars.PUBLIC_SITE_NAME }}
|
|
PUBLIC_SITE_DESC: ${{ vars.PUBLIC_SITE_DESC }}
|
|
USER_WATERMARK: ${{ vars.USER_WATERMARK }}
|
|
PUBLIC_EXTRA_HEAD_TAGS_PROD: ${{ vars.PUBLIC_EXTRA_HEAD_TAGS_PROD }}
|
|
DATABASE_URL: ${{ secrets.DATABASE_URL }}
|
|
steps:
|
|
- name: Docker meta
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
# list of Docker images to use as base name for tags
|
|
images: ${{ env.registry }}/${{ env.user }}/${{ env.image }}
|
|
# generate Docker tags based on the following events/attributes
|
|
tags: |
|
|
type=ref,event=branch
|
|
type=ref,event=pr
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
type=semver,pattern={{major}}
|
|
type=sha
|
|
- name: Login to Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.registry }}
|
|
username: ${{ env.user }}
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: "{{defaultContext}}:website"
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: type=registry,ref=${{ env.registry }}/${{ env.user }}/${{ env.image }}:buildcache
|
|
cache-to: type=registry,ref=${{ env.registry }}/${{ env.user }}/${{ env.image }}:buildcache,mode=max
|
|
|
|
deploy:
|
|
runs-on: ubuntu-full
|
|
needs: build
|
|
if: forgejo.ref == 'refs/head/master'
|
|
steps:
|
|
- name: Install SSH Key
|
|
uses: https://github.com/shimataro/ssh-key-action@v2.7.0
|
|
with:
|
|
key: ${{ secrets.REMOTE_PRIVATE_KEY }}
|
|
known_hosts: ${{ secrets.KNOWN_HOSTS }}
|
|
- name: pull changes & restart
|
|
run: ssh ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST}} -C "docker compose -f ${{ secrets.COMPOSE_PATH }} up -d --pull always --quiet-pull"
|