add pipeline
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
name: Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
cache: npm
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Typecheck
|
||||
run: npm run typecheck
|
||||
|
||||
- name: Build
|
||||
run: npm run build
|
||||
|
||||
- name: Run tests
|
||||
run: npm run test
|
||||
|
||||
build-and-push-image:
|
||||
runs-on: ubuntu-latest
|
||||
needs: test
|
||||
if: gitea.event_name == 'push'
|
||||
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Build image metadata
|
||||
id: image
|
||||
run: |
|
||||
REGISTRY="${{ vars.CONTAINER_REGISTRY }}"
|
||||
if [ -z "$REGISTRY" ]; then
|
||||
REGISTRY="$(printf '%s' '${{ gitea.server_url }}' | sed -E 's#^https?://##; s#/.*$##')"
|
||||
fi
|
||||
REGISTRY="$(printf '%s' "$REGISTRY" | tr '[:upper:]' '[:lower:]')"
|
||||
IMAGE_NAME="$(printf '%s' '${{ gitea.repository }}' | tr '[:upper:]' '[:lower:]')"
|
||||
SHORT_SHA="$(printf '%s' '${{ gitea.sha }}' | cut -c1-12)"
|
||||
|
||||
{
|
||||
echo "registry=${REGISTRY}"
|
||||
echo "image=${REGISTRY}/${IMAGE_NAME}"
|
||||
echo "sha_tag=${REGISTRY}/${IMAGE_NAME}:${SHORT_SHA}"
|
||||
echo "latest_tag=${REGISTRY}/${IMAGE_NAME}:latest"
|
||||
} >> "$GITEA_OUTPUT"
|
||||
|
||||
- name: Log in to Gitea container registry
|
||||
run: echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login "${{ steps.image.outputs.registry }}" --username "${{ secrets.REGISTRY_USERNAME }}" --password-stdin
|
||||
|
||||
- name: Build Docker image
|
||||
run: |
|
||||
docker build \
|
||||
--tag "${{ steps.image.outputs.sha_tag }}" \
|
||||
--tag "${{ steps.image.outputs.latest_tag }}" \
|
||||
.
|
||||
|
||||
- name: Push Docker image
|
||||
run: |
|
||||
docker push "${{ steps.image.outputs.sha_tag }}"
|
||||
docker push "${{ steps.image.outputs.latest_tag }}"
|
||||
Reference in New Issue
Block a user