All checks were successful
Anatid Blog CI Workflow / test (./backend) (push) Successful in 27s
Anatid Blog CI Workflow / test (./frontend) (push) Successful in 32s
Anatid Blog CI Workflow / build-and-push-images (./backend/Dockerfile, git.anatid.net/tabris/anatid-blog-backend, ./backend) (push) Successful in 35s
Anatid Blog CI Workflow / build-and-push-images (./frontend/Dockerfile, git.anatid.net/tabris/anatid-blog-frontend, ./frontend) (push) Successful in 43s
Anatid Blog CI Workflow / deploy (push) Successful in 23s
94 lines
2.9 KiB
YAML
94 lines
2.9 KiB
YAML
name: Anatid Blog CI Workflow
|
|
run-name: ${{ gitea.actor }} is running Anatid Blog Workflow
|
|
|
|
on:
|
|
push:
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: catthehacker/ubuntu:act-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- workingdir: ./backend
|
|
- workingdir: ./frontend
|
|
steps:
|
|
- name: Checkout
|
|
uses: https://github.com/actions/checkout@v4
|
|
- name: Use Node.js 18.19
|
|
uses: https://github.com/actions/setup-node@v3
|
|
with:
|
|
node-version: '18.19'
|
|
- name: Clean install
|
|
run: npm ci
|
|
working-directory: ./${{ matrix.workingdir }}
|
|
- name: Run lint
|
|
run: npm run lint
|
|
working-directory: ./${{ matrix.workingdir }}
|
|
- name: Run tests
|
|
run: npm run test
|
|
working-directory: ./${{ matrix.workingdir }}
|
|
|
|
build-and-push-images:
|
|
needs: test
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: catthehacker/ubuntu:act-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- workingdir: ./backend
|
|
dockerfile: ./backend/Dockerfile
|
|
image: git.anatid.net/tabris/anatid-blog-backend
|
|
- workingdir: ./frontend
|
|
dockerfile: ./frontend/Dockerfile
|
|
image: git.anatid.net/tabris/anatid-blog-frontend
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
- name: Loging to docker hub registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ vars.DOCKER_HUB_USERNAME }}
|
|
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
|
|
- name: Login to gitea container registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: git.anatid.net
|
|
username: ${{ vars.REPO_USERNAME }}
|
|
password: ${{ secrets.REPO_PASSWORD }}
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
working-directory: ./${{ matrix.workingdir }}
|
|
- name: Extract metadata (tags, labels) for Docker
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
working-directory: ./${{ matrix.workingdir }}
|
|
with:
|
|
images: ${{ matrix.image }}
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v6
|
|
working-directory: ./${{ matrix.workingdir }}
|
|
with:
|
|
context: ./${{ matrix.workingdir }}
|
|
file: ${{ matrix.dockerfile }}
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
deploy:
|
|
needs: build-and-push-images
|
|
runs-on: self-hosted
|
|
defaults:
|
|
run:
|
|
working-directory: /home/web
|
|
steps:
|
|
- name: Pull docker containers
|
|
run: docker compose pull
|
|
- name: Start containers
|
|
run: docker compose up -d anatid-blog-frontend anatid-blog-backend
|