diff --git a/.github/workflows/build-containers.yml b/.github/workflows/build-containers.yml index a3dfadc1..a0d83a75 100644 --- a/.github/workflows/build-containers.yml +++ b/.github/workflows/build-containers.yml @@ -8,8 +8,27 @@ on: - '*' jobs: - build-containers: + build-containers-common: runs-on: ubuntu-latest + outputs: + containerver: ${{ steps.getcontainerver.outputs.containerver }} + steps: + - name: Get Container Version + id: getcontainerver + run: | + echo "containerver=$(date +'%s')" >> "$GITHUB_OUTPUT" + + build-containers: + needs: build-containers-common + strategy: + matrix: + include: + - runnertags: ubuntu-latest + arch: amd64 + - runnertags: [self-hosted, ARM64] + arch: arm64 + + runs-on: ${{ matrix.runnertags }} steps: - name: Checkout uses: actions/checkout@v4 @@ -26,24 +45,41 @@ jobs: - name: docker build run: ./var/docker/docker-build.sh - - name: Get date - run: | - echo "DATE=$(date +'%s')" >> "$GITHUB_ENV" - - name: Print post-build debug info run: | docker images - name: docker tag + env: + CONTAINERVER: ${{ needs.build-containers-common.outputs.containerver }} run: | - docker tag localhost/postiz ghcr.io/gitroomhq/postiz-app:${{ env.DATE }} - docker push ghcr.io/gitroomhq/postiz-app:${{ env.DATE }} + docker tag localhost/postiz ghcr.io/gitroomhq/postiz-app:${{ matrix.arch }}-${{ env.CONTAINERVER }} + docker push ghcr.io/gitroomhq/postiz-app:${{ matrix.arch }}-${{ env.CONTAINERVER }} - docker tag ghcr.io/gitroomhq/postiz-app:${{ env.DATE }} ghcr.io/gitroomhq/postiz-app:latest - docker push ghcr.io/gitroomhq/postiz-app:latest + docker tag localhost/postiz-devcontainer ghcr.io/gitroomhq/postiz-devcontainer:${{ env.CONTAINERVER }} + docker push ghcr.io/gitroomhq/postiz-devcontainer:${{ env.CONTAINERVER }} - docker tag localhost/postiz-devcontainer ghcr.io/gitroomhq/postiz-devcontainer:${{ env.DATE }} - docker push ghcr.io/gitroomhq/postiz-devcontainer:${{ env.DATE }} - - docker tag ghcr.io/gitroomhq/postiz-devcontainer:${{ env.DATE }} ghcr.io/gitroomhq/postiz-devcontainer:latest + docker tag ghcr.io/gitroomhq/postiz-devcontainer:${{ env.CONTAINERVER }} ghcr.io/gitroomhq/postiz-devcontainer:latest docker push ghcr.io/gitroomhq/postiz-devcontainer:latest + + build-container-manifest: + needs: [build-containers, build-containers-common] + runs-on: ubuntu-latest + steps: + - name: Login to ghcr + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ github.token }} + + - name: Create Docker Manifest + env: + CONTAINERVER: ${{ needs.build-containers-common.outputs.containerver }} + run: | + docker manifest create \ + ghcr.io/gitroomhq/postiz-app:latest \ + ghcr.io/gitroomhq/postiz-app:amd64-${{ env.CONTAINERVER }} \ + ghcr.io/gitroomhq/postiz-app:arm64-${{ env.CONTAINERVER }} + + docker manifest push ghcr.io/gitroomhq/postiz-app:latest diff --git a/apps/frontend/src/components/auth/register.tsx b/apps/frontend/src/components/auth/register.tsx index ff678025..67fefbdf 100644 --- a/apps/frontend/src/components/auth/register.tsx +++ b/apps/frontend/src/components/auth/register.tsx @@ -65,6 +65,17 @@ export function Register() { ); } +function getHelpfulReasonForRegistrationFailure(httpCode: number) { + switch (httpCode) { + case 400: + return 'Email already exists'; + case 404: + return 'Your browser got a 404 when trying to contact the API, the most likely reasons for this are the NEXT_PUBLIC_BACKEND_URL is set incorrectly, or the backend is not running.'; + } + + return 'Unhandled error: ' + httpCode; +} + export function RegisterAfter({ token, provider, @@ -97,23 +108,31 @@ export function RegisterAfter({ const onSubmit: SubmitHandler = async (data) => { setLoading(true); - const register = await fetchData('/auth/register', { + + await fetchData('/auth/register', { method: 'POST', body: JSON.stringify({ ...data }), - }); - if (register.status === 400) { - form.setError('email', { - message: 'Email already exists', - }); - + }).then((response) => { setLoading(false); - } - fireEvents('register'); + if (response.status === 200) { + fireEvents('register') - if (register.headers.get('activate')) { - router.push('/auth/activate'); - } + if (response.headers.get('activate') === "true") { + router.push('/auth/activate'); + } else { + router.push('/auth/login'); + } + } else { + form.setError('email', { + message: getHelpfulReasonForRegistrationFailure(response.status), + }); + } + }).catch(e => { + form.setError("email", { + message: 'General error: ' + e.toString() + '. Please check your browser console.', + }); + }) }; return (