{"id":18622060,"url":"https://github.com/caprover/deploy-from-github","last_synced_at":"2025-04-05T22:06:12.787Z","repository":{"id":51680506,"uuid":"519953431","full_name":"caprover/deploy-from-github","owner":"caprover","description":null,"archived":false,"fork":false,"pushed_at":"2024-11-07T01:58:56.000Z","size":18,"stargazers_count":61,"open_issues_count":1,"forks_count":19,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-29T21:04:51.626Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/caprover.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-01T03:39:26.000Z","updated_at":"2024-12-18T15:23:23.000Z","dependencies_parsed_at":"2024-12-30T07:18:32.427Z","dependency_job_id":null,"html_url":"https://github.com/caprover/deploy-from-github","commit_stats":{"total_commits":12,"total_committers":2,"mean_commits":6.0,"dds":"0.33333333333333337","last_synced_commit":"4f2b50c37be9f3f325c67b16660e321395841040"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caprover%2Fdeploy-from-github","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caprover%2Fdeploy-from-github/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caprover%2Fdeploy-from-github/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caprover%2Fdeploy-from-github/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/caprover","download_url":"https://codeload.github.com/caprover/deploy-from-github/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247406087,"owners_count":20933803,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T04:15:01.723Z","updated_at":"2025-04-05T22:06:12.748Z","avatar_url":"https://github.com/caprover.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deploy from Github\n\nThis Github Action leverages the official Caprover CLI and the App Token strategy to deploy an app directly from Github.\nAn example workflow provided below, shows how we can automagically create a deploy.tar file as a required part of a build \u0026 deployment strategy.\n\nUsing this Github Action requires the following three pieces of information to be entered into Github Secrets for your project repository:\n\n- `app` secret is the name of your app, exactly as it's specified in Caprover.\n- `token` secret is obtained fromt he \"Deployment\" tab of the app in Caprover. Click \"Enable App Token\" to generate a token.\n- `server` secret can be organization-wide, per project, or per project override and in the format of https://captain.apps.your-domain.com.\nOptional:\n- `image` secret can be used to specify the specific image you want to deploy, this is particularly useful when you want to build on Github.\n- `branch` secret can be used to specify the branch you want to deploy to CapRover.\n- If `image` and `branch` are empty, this action expects a tar file located at the root of the project `./deploy.tar` to deploy\n\n\n\n### Example 1 - deploy using image:\nThis method is preferred because you end up using Github servers to build your image and your own CapRover server just receives the built image. This is very useful specially if your server resources are limited.\nSpecify `CAPROVER_APP_TOKEN` and `CAPROVER_HOST` as secret in your repo. Also change `env` section in the action and you're good to go!\n\n\n```yaml\nname: Deploy to staging\n\nenv:\n    CONTEXT_DIR: './'\n    IMAGE_NAME: ${{ github.repository }}/staging\n    DOCKERFILE: Dockerfile.staging\n    CAPROVER_APP: myapp-staging\n    DOCKER_REGISTRY: ghcr.io\n\non:\n    push:\n        branches:\n            - main\n        # 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\n        # paths:\n        #   - \"backend-app/**\"\n\njobs:\n    build-and-publish:\n        runs-on: ubuntu-latest\n        steps:\n            - uses: actions/checkout@v1\n            - run: |\n                  echo \"IMAGE_NAME_WITH_REGISTRY=$DOCKER_REGISTRY/$IMAGE_NAME\" \u003e\u003e $GITHUB_ENV\n                  export IMAGE_NAME_WITH_REGISTRY=$DOCKER_REGISTRY/$IMAGE_NAME\n                  echo \"FULL_IMAGE_NAME=$IMAGE_NAME_WITH_REGISTRY:$GITHUB_SHA-gitsha\" \u003e\u003e $GITHUB_ENV\n                  echo \"CAPROVER_GIT_COMMIT_SHA=$GITHUB_SHA\" \u003e\u003e $GITHUB_ENV\n            - name: Log in to the Container registry\n              uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9\n              with:\n                  registry: ${{ env.DOCKER_REGISTRY }}\n                  username: ${{ github.actor }}\n                  password: ${{ secrets.GITHUB_TOKEN }}\n            - name: Build and Push Release to DockerHub\n              shell: bash\n              run: ./build_and_push.sh\n            - name: Deploy to CapRover\n              uses: caprover/deploy-from-github@d76580d79952f6841c453bb3ed37ef452b19752c\n              with:\n                  server: ${{ secrets.CAPROVER_HOST }}\n                  app: ${{ env.CAPROVER_APP }}\n                  token: '${{ secrets.CAPROVER_APP_TOKEN }}'\n                  image: '${{ env.FULL_IMAGE_NAME }}'\n\n```\n\n`build_and_push.sh`\n```bash\n#!/bin/bash\n\nset -e\n\ncd $CONTEXT_DIR\nrm /tmp/build_args || echo OK\nenv \u003e/tmp/build_args\necho \"--build-arg \\\"\"$(cat /tmp/build_args | sed -z 's/\\n/\" --build-arg \"/g')\"IGNORE_VAR=IGNORE_VAR\\\"\" \u003e/tmp/build_args\nBUILD_ARGS=$(cat /tmp/build_args)\nCOMMAND=\"docker build -t $FULL_IMAGE_NAME -t $IMAGE_NAME_WITH_REGISTRY:latest -f $DOCKERFILE $BUILD_ARGS --no-cache .\"\n/bin/bash -c \"$COMMAND\"\ndocker push $IMAGE_NAME_WITH_REGISTRY:latest\ndocker push $FULL_IMAGE_NAME\nrm /tmp/build_args\n\n```\n\n### Example 2 - deploy using `./deploy.tar`\n\nThe example workflow contains a few steps to process your source code into a deployed app in Caprover. The first step uses the a CI/CD version of Node Package Manager (NPM) to build the front-end from source code. The second step packages up your newly minted dist/ directory, the existing backend/ directory and captain-definition file into a deploy.tar file. In the last step the deploy.tar file is picked up by this Github Action and using the provided secrets, will send the file to the Caprover server where it will be deployed.\n\n```yaml\nname: Build App \u0026 Deploy\n\non:\n  push:\n    branches: [ \"main\" ]\n\n  pull_request:\n    branches: [ \"main\" ]\n\njobs:\n  build-and-deploy:\n    runs-on: ubuntu-latest\n\n    strategy:\n      matrix:\n        node-version: [18.x]\n\n    steps:\n      - uses: actions/checkout@v3\n      - name: Use Node.js ${{ matrix.node-version }}\n        uses: actions/setup-node@v3\n        with:\n          node-version: ${{ matrix.node-version }}\n          cache: \"npm\"\n      - run: npm ci\n      - run: npm run build --if-present\n      - run: npm run test --if-present\n\n      # Future plans in the works to create tarball from within the caprover/deploy-from-github action.\n      - uses: a7ul/tar-action@v1.1.0\n        with:\n          command: c\n          cwd: \"./\"\n          files: |\n            backend/\n            frontend/dist/\n            captain-definition\n          outPath: deploy.tar\n\n      - uses: caprover/deploy-from-github@main\n        with:\n          server: '${{ secrets.CAPROVER_SERVER }}'\n          app: '${{ secrets.APP_NAME }}'\n          token: '${{ secrets.APP_TOKEN }}'\n          branch: '${{ secrets.DEPLOY_BRANCH }}' # optional\n          image: '${{ secrets.DEPLOY_IMAGE }}' # optional\n\n```\n\nNOTE: Deployments take place within seconds after the workflow has been processed succesfully with any failed deployments sending an email alert to your email on file with Github.\n\nFor more information:\n\nA complete Vue 3 frontend starter project that includes a PHP backend that uses this Github Action can be found at https://github.com/PremoWeb/SDK-Foundation-Vue/.\nThe example workflow presented on this page was sourced from https://github.com/PremoWeb/SDK-Foundation-Vue/blob/main/.github/workflows/deploy.yml.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaprover%2Fdeploy-from-github","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcaprover%2Fdeploy-from-github","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaprover%2Fdeploy-from-github/lists"}