Skip to content

Commit b4beee6

Browse files
author
Nevo David
committed
Merge remote-tracking branch 'origin/main'
2 parents 3db3613 + e3b1966 commit b4beee6

File tree

2 files changed

+81
-26
lines changed

2 files changed

+81
-26
lines changed

.github/workflows/build-containers.yml

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,27 @@ on:
88
- '*'
99

1010
jobs:
11-
build-containers:
11+
build-containers-common:
1212
runs-on: ubuntu-latest
13+
outputs:
14+
containerver: ${{ steps.getcontainerver.outputs.containerver }}
15+
steps:
16+
- name: Get Container Version
17+
id: getcontainerver
18+
run: |
19+
echo "containerver=$(date +'%s')" >> "$GITHUB_OUTPUT"
20+
21+
build-containers:
22+
needs: build-containers-common
23+
strategy:
24+
matrix:
25+
include:
26+
- runnertags: ubuntu-latest
27+
arch: amd64
28+
- runnertags: [self-hosted, ARM64]
29+
arch: arm64
30+
31+
runs-on: ${{ matrix.runnertags }}
1332
steps:
1433
- name: Checkout
1534
uses: actions/checkout@v4
@@ -26,24 +45,41 @@ jobs:
2645
- name: docker build
2746
run: ./var/docker/docker-build.sh
2847

29-
- name: Get date
30-
run: |
31-
echo "DATE=$(date +'%s')" >> "$GITHUB_ENV"
32-
3348
- name: Print post-build debug info
3449
run: |
3550
docker images
3651
3752
- name: docker tag
53+
env:
54+
CONTAINERVER: ${{ needs.build-containers-common.outputs.containerver }}
3855
run: |
39-
docker tag localhost/postiz ghcr.io/gitroomhq/postiz-app:${{ env.DATE }}
40-
docker push ghcr.io/gitroomhq/postiz-app:${{ env.DATE }}
41-
42-
docker tag ghcr.io/gitroomhq/postiz-app:${{ env.DATE }} ghcr.io/gitroomhq/postiz-app:latest
43-
docker push ghcr.io/gitroomhq/postiz-app:latest
56+
docker tag localhost/postiz ghcr.io/gitroomhq/postiz-app:${{ matrix.arch }}-${{ env.CONTAINERVER }}
57+
docker push ghcr.io/gitroomhq/postiz-app:${{ matrix.arch }}-${{ env.CONTAINERVER }}
4458
45-
docker tag localhost/postiz-devcontainer ghcr.io/gitroomhq/postiz-devcontainer:${{ env.DATE }}
46-
docker push ghcr.io/gitroomhq/postiz-devcontainer:${{ env.DATE }}
59+
docker tag localhost/postiz-devcontainer ghcr.io/gitroomhq/postiz-devcontainer:${{ env.CONTAINERVER }}
60+
docker push ghcr.io/gitroomhq/postiz-devcontainer:${{ env.CONTAINERVER }}
4761
48-
docker tag ghcr.io/gitroomhq/postiz-devcontainer:${{ env.DATE }} ghcr.io/gitroomhq/postiz-devcontainer:latest
62+
docker tag ghcr.io/gitroomhq/postiz-devcontainer:${{ env.CONTAINERVER }} ghcr.io/gitroomhq/postiz-devcontainer:latest
4963
docker push ghcr.io/gitroomhq/postiz-devcontainer:latest
64+
65+
build-container-manifest:
66+
needs: [build-containers, build-containers-common]
67+
runs-on: ubuntu-latest
68+
steps:
69+
- name: Login to ghcr
70+
uses: docker/login-action@v3
71+
with:
72+
registry: ghcr.io
73+
username: ${{ github.actor }}
74+
password: ${{ github.token }}
75+
76+
- name: Create Docker Manifest
77+
env:
78+
CONTAINERVER: ${{ needs.build-containers-common.outputs.containerver }}
79+
run: |
80+
docker manifest create \
81+
ghcr.io/gitroomhq/postiz-app:latest \
82+
ghcr.io/gitroomhq/postiz-app:amd64-${{ env.CONTAINERVER }} \
83+
ghcr.io/gitroomhq/postiz-app:arm64-${{ env.CONTAINERVER }}
84+
85+
docker manifest push ghcr.io/gitroomhq/postiz-app:latest

apps/frontend/src/components/auth/register.tsx

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ export function Register() {
6565
);
6666
}
6767

68+
function getHelpfulReasonForRegistrationFailure(httpCode: number) {
69+
switch (httpCode) {
70+
case 400:
71+
return 'Email already exists';
72+
case 404:
73+
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.';
74+
}
75+
76+
return 'Unhandled error: ' + httpCode;
77+
}
78+
6879
export function RegisterAfter({
6980
token,
7081
provider,
@@ -97,23 +108,31 @@ export function RegisterAfter({
97108

98109
const onSubmit: SubmitHandler<Inputs> = async (data) => {
99110
setLoading(true);
100-
const register = await fetchData('/auth/register', {
111+
112+
await fetchData('/auth/register', {
101113
method: 'POST',
102114
body: JSON.stringify({ ...data }),
103-
});
104-
if (register.status === 400) {
105-
form.setError('email', {
106-
message: 'Email already exists',
107-
});
108-
115+
}).then((response) => {
109116
setLoading(false);
110-
}
111-
112-
fireEvents('register');
113117

114-
if (register.headers.get('activate')) {
115-
router.push('/auth/activate');
116-
}
118+
if (response.status === 200) {
119+
fireEvents('register')
120+
121+
if (response.headers.get('activate') === "true") {
122+
router.push('/auth/activate');
123+
} else {
124+
router.push('/auth/login');
125+
}
126+
} else {
127+
form.setError('email', {
128+
message: getHelpfulReasonForRegistrationFailure(response.status),
129+
});
130+
}
131+
}).catch(e => {
132+
form.setError("email", {
133+
message: 'General error: ' + e.toString() + '. Please check your browser console.',
134+
});
135+
})
117136
};
118137

119138
return (

0 commit comments

Comments
 (0)