caprover / deploy-from-github

Apache License 2.0
60 stars 18 forks source link

deploy failed error #7

Closed smyja closed 1 year ago

smyja commented 1 year ago

I am trying to deploy a nextjs app and i keep getting this error in the build logs, my repo is not associated with any organization also. its just a private repo.

Build started for scrapeweb
An explicit image name was provided (ghcr.io/smyja/scrapweb:df37ec852f198237d0b214848675edf0df0f99b6-gitsha). Therefore, no build process is needed.
Pulling this image: ghcr.io/smyja/scrapweb:df37ec852f198237d0b214848675edf0df0f99b6-gitsha This process might take a few minutes.
Build has failed!
----------------------
Deploy failed!
Error: (HTTP code 500) server error - Head "https://ghcr.io/v2/smyja/scrapweb/manifests/df37ec852f198237d0b214848675edf0df0f99b6-gitsha": denied

here is my build_and_push.sh

#!/bin/bash

set -e

cd $CONTEXT_DIR
rm /tmp/build_args || echo OK
env >/tmp/build_args
echo "--build-arg \""$(cat /tmp/build_args | sed -z 's/\n/" --build-arg "/g')"IGNORE_VAR=IGNORE_VAR\"" >/tmp/build_args
BUILD_ARGS=$(cat /tmp/build_args)
docker logout ghcr.io
COMMAND="docker build -t $FULL_IMAGE_NAME -t $IMAGE_NAME_WITH_REGISTRY:latest -f $DOCKERFILE $BUILD_ARGS --no-cache ."
/bin/bash -c "$COMMAND"
docker push $IMAGE_NAME_WITH_REGISTRY:latest
docker push $FULL_IMAGE_NAME
rm /tmp/build_args

Here is my yaml file

name: Deploy to caprover

env:
    CONTEXT_DIR: './'
    IMAGE_NAME: ${{ github.repository }}
    DOCKERFILE: ./Dockerfile
    # CAPROVER_APP: myapp-staging
    DOCKER_REGISTRY: ghcr.io

on:
    push:
        branches:
            - main
        # you can specify path if you have a monorepo and you want to deploy if particular directory is changed, make sure to update `CONTEXT_DIR` too
        # paths:
        #   - "backend-app/**"

jobs:
    build-and-publish:
        runs-on: ubuntu-latest
        steps:
            - uses: actions/checkout@v1
            - run: |
                  echo "IMAGE_NAME_WITH_REGISTRY=$DOCKER_REGISTRY/$IMAGE_NAME" >> $GITHUB_ENV
                  export IMAGE_NAME_WITH_REGISTRY=$DOCKER_REGISTRY/$IMAGE_NAME
                  echo "FULL_IMAGE_NAME=$IMAGE_NAME_WITH_REGISTRY:$GITHUB_SHA-gitsha" >> $GITHUB_ENV

            - name: Log in to the Container registry
              uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
              with:
                  registry: ${{ env.DOCKER_REGISTRY }}
                  username: ${{ github.actor }}
                  password: ${{ secrets.GITHUB_TOKEN }}

            - name: Build and Push Release to DockerHub
              shell: bash
              run: chmod +x ./build_and_push.sh

            - name: Use Node.js ${{ matrix.node-version }}
              uses: actions/setup-node@v3
              with:
                node-version: ${{ matrix.node-version }}
                cache: "npm"
            - run: npm ci
            - run: npm run build --if-present
            - run: npm run test --if-present

            - name: Deploy to CapRover
              uses: caprover/deploy-from-github@d76580d79952f6841c453bb3ed37ef452b19752c
              with:
                  server: ${{ secrets.CAPROVER_SERVER }}
                  app: ${{ secrets.APP_NAME }}
                  token: '${{ secrets.APP_TOKEN }}'
                  image: '${{ env.FULL_IMAGE_NAME }}'
githubsaturn commented 1 year ago

Dupe of https://github.com/caprover/caprover/issues/1756