diff --git a/.github/workflows/build-push-deploy-dev.yaml b/.github/workflows/build-push-deploy-dev.yaml new file mode 100644 index 0000000..31c097b --- /dev/null +++ b/.github/workflows/build-push-deploy-dev.yaml @@ -0,0 +1,62 @@ +name: build push deploy dev + +on: + push: + branches: + - dev + - cicd + workflow_dispatch: +env: + REPO_NAME: ${{ github.event.repository.name }} + BRANCH_NAME: "${{ github.ref_name }}" + FULL_COMMIT_HASH: "${{ github.sha }}" + IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }} +jobs: + # This pushes the image to GitHub Packages. + build-push-deploy: + runs-on: ubuntu-latest + permissions: + packages: write + contents: write + steps: + - uses: actions/checkout@v4 + - name: Docker sanity + run: | + echo "Runner: $(uname -a)" + docker --version || true + ls -la + - name: set env + run: | + SHORT_COMMIT_HASH="${FULL_COMMIT_HASH:0:8}" + echo "SHORT_COMMIT_HASH=$SHORT_COMMIT_HASH" >> $GITHUB_ENV + echo "FULL_COMMIT_HASH=$FULL_COMMIT_HASH" >> $GITHUB_ENV + - name: print env + run: | + echo $REPO_NAME + echo $BRANCH_NAME + echo $FULL_COMMIT_HASH + echo $SHORT_COMMIT_HASH + echo $IMAGE_NAME + - name: docker login + run: | + echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + - name: build + run: | + docker pull $IMAGE_NAME:latest || echo "warn: image is not found" + docker build . --tag $IMAGE_NAME:$BRANCH_NAME --tag $IMAGE_NAME:$BRANCH_NAME-$FULL_COMMIT_HASH --tag $IMAGE_NAME:$BRANCH_NAME-$SHORT_COMMIT_HASH --tag $IMAGE_NAME:latest --label "runnumber=${GITHUB_RUN_ID}" + - name: docker image ls + run: | + docker image ls + - name: push + run: | + docker push $IMAGE_NAME:latest + docker push $IMAGE_NAME:$BRANCH_NAME + docker push $IMAGE_NAME:$BRANCH_NAME-$FULL_COMMIT_HASH + docker push $IMAGE_NAME:$BRANCH_NAME-$SHORT_COMMIT_HASH + - name: git tag + run: | + TAG_NAME="dev-server-all" + git config user.name "GitHub Actions Bot" + git config user.email "actions@github.com" + git tag -f $TAG_NAME + git push -f origin $TAG_NAME \ No newline at end of file diff --git a/.gitignore b/.gitignore index 10f8470..09bdfde 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,10 @@ node_modules out .env*.local + +# IDE +.idea +.DS_Store + +# Create Fake Data +create-fake-orders.sh \ No newline at end of file diff --git a/lib/api/axiosInstance.ts b/lib/api/axiosInstance.ts index 786d288..28cfe6b 100644 --- a/lib/api/axiosInstance.ts +++ b/lib/api/axiosInstance.ts @@ -43,10 +43,16 @@ export const defaultMutator = ( url: string, config?: RequestInit ): Promise => { + const isFormData = config?.body instanceof FormData; + return AXIOS_INSTANCE({ url, - method: config?.method as AxiosRequestConfig['method'], - headers: config?.headers as AxiosRequestConfig['headers'], + method: config?.method as AxiosRequestConfig["method"], + headers: { + ...(config?.headers as AxiosRequestConfig["headers"]), + // Remove Content-Type for FormData so Axios sets multipart/form-data with boundary automatically + ...(isFormData && { "Content-Type": undefined }), + }, data: config?.body, }).then((res) => res.data); };