Compare commits

..

No commits in common. "3adbea7d44f24bdadaf5ba941ff1c222c5a39ab1" and "392729c2d4ef9043e1144f8a56e17f1dd2a68df9" have entirely different histories.

2 changed files with 49 additions and 11 deletions

View file

@ -25,7 +25,7 @@ jobs:
- name: Copy frontend to host pages mount - name: Copy frontend to host pages mount
if: github.event_name == 'push' && github.ref == 'refs/heads/main' if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: http://forgejo:3000/andras/ci-actions/deploy-pages@main run: |
with: apt update && apt install -y rsync
source: frontend mkdir -p /pages
target: fizika rsync -a --delete frontend/ /pages/fizika

View file

@ -8,6 +8,9 @@ on:
branches: ['main'] branches: ['main']
workflow_dispatch: workflow_dispatch:
env:
IMAGE_NAME: ${{ forgejo.repository }}/fizika-admin
jobs: jobs:
build-and-push: build-and-push:
runs-on: docker runs-on: docker
@ -16,10 +19,45 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: https://code.forgejo.org/actions/checkout@v4 uses: https://code.forgejo.org/actions/checkout@v4
- name: Build and publish admin image - name: Extract registry host
uses: http://forgejo:3000/andras/ci-actions/docker-publish@main id: registry
with: run: echo "host=$(echo '${{ forgejo.server_url }}' | sed 's|https\?://||')" >> "$GITHUB_OUTPUT"
context: ./backend
image-suffix: /fizika-admin - name: Log into Forgejo registry
push: ${{ github.event_name != 'pull_request' }} if: forgejo.event_name != 'pull_request'
token: ${{ secrets.FORGEJO_PACKAGE_TOKEN }} run: echo "${{ secrets.FORGEJO_PACKAGE_TOKEN }}" | docker login "${{ steps.registry.outputs.host }}" -u "${{ forgejo.actor }}" --password-stdin
- name: Build Docker image
run: |
IMAGE="${{ steps.registry.outputs.host }}/$(echo "${{ env.IMAGE_NAME }}" | tr '[:upper:]' '[:lower:]')"
SHA_SHORT="$(echo "${{ forgejo.sha }}" | cut -c1-12)"
TAG_ARGS="-t ${IMAGE}:sha-${SHA_SHORT}"
if [ "${{ forgejo.ref }}" = "refs/heads/main" ]; then
TAG_ARGS="${TAG_ARGS} -t ${IMAGE}:main -t ${IMAGE}:latest"
fi
if [ "${{ forgejo.ref_type }}" = "tag" ]; then
REF_NAME="${{ forgejo.ref_name }}"
TAG_ARGS="${TAG_ARGS} -t ${IMAGE}:${REF_NAME}"
if echo "$REF_NAME" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
VERSION="${REF_NAME#v}"
MAJOR_MINOR="$(echo "$VERSION" | cut -d. -f1,2)"
MAJOR="$(echo "$VERSION" | cut -d. -f1)"
TAG_ARGS="${TAG_ARGS} -t ${IMAGE}:${VERSION} -t ${IMAGE}:${MAJOR_MINOR} -t ${IMAGE}:${MAJOR}"
fi
fi
docker build \
--label "org.opencontainers.image.source=${{ forgejo.server_url }}/${{ forgejo.repository }}" \
--label "org.opencontainers.image.revision=${{ forgejo.sha }}" \
--label "org.opencontainers.image.created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
${TAG_ARGS} \
./backend
echo "IMAGE=${IMAGE}" >> "$GITHUB_ENV"
- name: Push Docker image
if: forgejo.event_name != 'pull_request'
run: docker push --all-tags "$IMAGE"