Containerize the app for local and production deploys, and publish images to the Gitea container registry on main pushes and version tags. Co-authored-by: Cursor <cursoragent@cursor.com>
93 lines
2.7 KiB
YAML
93 lines
2.7 KiB
YAML
name: Docker Release
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
tags: ["v*"]
|
|
|
|
env:
|
|
REGISTRY: gitea.scoutitsystems.com
|
|
# Gitea container registry: {registry}/{owner}/{image}
|
|
IMAGE: gitea.scoutitsystems.com/woogi/conflict-checker
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: self-hosted
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Image tags
|
|
id: meta
|
|
run: |
|
|
short_sha="${GITEA_SHA:-${GITHUB_SHA}}"
|
|
short_sha="${short_sha:0:7}"
|
|
echo "short_sha=${short_sha}" >> "$GITHUB_OUTPUT"
|
|
|
|
{
|
|
echo "tags<<EOF"
|
|
echo "${IMAGE}:latest"
|
|
echo "${IMAGE}:sha-${short_sha}"
|
|
if [ "${GITEA_REF_TYPE:-${GITHUB_REF_TYPE}}" = "tag" ]; then
|
|
ref_name="${GITEA_REF_NAME:-${GITHUB_REF_NAME}}"
|
|
echo "${IMAGE}:${ref_name}"
|
|
echo "${IMAGE}:${ref_name#v}"
|
|
fi
|
|
echo "EOF"
|
|
} >> "$GITHUB_OUTPUT"
|
|
env:
|
|
IMAGE: ${{ env.IMAGE }}
|
|
GITEA_SHA: ${{ gitea.sha }}
|
|
GITHUB_SHA: ${{ github.sha }}
|
|
GITEA_REF_TYPE: ${{ gitea.ref_type }}
|
|
GITHUB_REF_TYPE: ${{ github.ref_type }}
|
|
GITEA_REF_NAME: ${{ gitea.ref_name }}
|
|
GITHUB_REF_NAME: ${{ github.ref_name }}
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to Gitea Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ gitea.actor }}
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
release:
|
|
needs: build-and-push
|
|
if: gitea.ref_type == 'tag' || github.ref_type == 'tag'
|
|
runs-on: self-hosted
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Publish Gitea release
|
|
uses: https://gitea.com/actions/gitea-release-action@v1
|
|
env:
|
|
NODE_OPTIONS: "--experimental-fetch"
|
|
with:
|
|
token: ${{ secrets.REGISTRY_TOKEN }}
|
|
tag_name: ${{ gitea.ref_name }}
|
|
name: Conflict Checker ${{ gitea.ref_name }}
|
|
body: |
|
|
## Docker
|
|
|
|
```bash
|
|
docker login gitea.scoutitsystems.com
|
|
docker pull gitea.scoutitsystems.com/woogi/conflict-checker:${{ gitea.ref_name }}
|
|
```
|
|
|
|
Deploy on a host (with `docker-compose.prod.yml` and `backend/.env`):
|
|
|
|
```bash
|
|
IMAGE_TAG=${{ gitea.ref_name }} docker compose -f docker-compose.prod.yml up -d
|
|
```
|