Merge remote-tracking branch 'origin/main'

This commit is contained in:
Nevo David 2024-09-25 11:13:21 +07:00
commit b4beee65da
2 changed files with 80 additions and 25 deletions

View File

@ -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

View File

@ -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<Inputs> = 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 (