80 lines
2.3 KiB
YAML
80 lines
2.3 KiB
YAML
name: release-crud-api
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'crud-api/v*'
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Extract version from tag
|
|
id: meta
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
TAG="${GITHUB_REF_NAME}"
|
|
VERSION="${TAG#crud-api/v}"
|
|
echo "version=${VERSION}" >> "${GITHUB_OUTPUT}"
|
|
|
|
- name: Build Docker image (root context)
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
docker build \
|
|
--file apps/crud-api/Dockerfile \
|
|
--tag crud-api:${{ steps.meta.outputs.version }} \
|
|
.
|
|
|
|
- name: Package tar + filtered env
|
|
id: bundle
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
VERSION="${{ steps.meta.outputs.version }}"
|
|
OUT_DIR="dist/release"
|
|
TAR_PATH="${OUT_DIR}/crud-api-${VERSION}.tar"
|
|
ZIP_PATH="${OUT_DIR}/crud-api-${VERSION}-deploy-bundle.zip"
|
|
ENV_PATH="${OUT_DIR}/crud-api.env"
|
|
|
|
mkdir -p "${OUT_DIR}"
|
|
docker save --output "${TAR_PATH}" "crud-api:${VERSION}"
|
|
|
|
if [ ! -f .env.production ]; then
|
|
echo ".env.production is missing at repository root" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Keep only variables needed by crud-api deployment.
|
|
grep -E '^(NODE_ENV|CRUD_|DATABASE_URL|REDIS_URL)=' .env.production > "${ENV_PATH}"
|
|
|
|
zip -j "${ZIP_PATH}" "${TAR_PATH}" "${ENV_PATH}"
|
|
echo "zip_path=${ZIP_PATH}" >> "${GITHUB_OUTPUT}"
|
|
|
|
- name: Verify bundle content
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
unzip -l "${{ steps.bundle.outputs.zip_path }}"
|
|
|
|
- name: Create Gitea release with artifact
|
|
uses: https://gitea.com/actions/gitea-release-action@v1
|
|
with:
|
|
token: ${{ secrets.RELEASE_TOKEN }}
|
|
tag_name: ${{ github.ref_name }}
|
|
name: crud-api v${{ steps.meta.outputs.version }}
|
|
body: |
|
|
Automated release bundle for crud-api.
|
|
Download the attached *-deploy-bundle.zip asset from this release.
|
|
Includes:
|
|
- Docker image tar
|
|
- filtered crud-api.env for deploy
|
|
files: |
|
|
${{ steps.bundle.outputs.zip_path }}
|