Skip to content

Commit

Permalink
Add action
Browse files Browse the repository at this point in the history
  • Loading branch information
JasirZaeem committed Jun 11, 2021
1 parent 0ecd276 commit 08bea18
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "Deploy to Caprover"

description: "An Action to build a docker image and deploy to Caprover"
author: "Jasir Zaeem"

branding:
icon: upload-cloud
color: gray-dark
inputs:
token:
description: "GITHUB_TOKEN"
required: true
server:
description: "Captain URL for your CapRover server."
required: true
password:
description: "Admin password for your CapRover server."
required: true
app:
description: "Application name to deploy this repo to, must have been created."
required: true
runs:
using: composite
steps:
- run: |
export REPO=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')
export REGISTRY_USER=${{ github.actor }}
export REGISTRY_PASSWORD=${{inputs.token}}
export REGISTRY_URL="ghcr.io"
export COMMIT_HASH=$GITHUB_SHA
export IMAGE_NAME_WITH_REGISTRY_PREFIX=ghcr.io/$REPO
docker login -u "$REGISTRY_USER" -p "$REGISTRY_PASSWORD" $REGISTRY_URL
echo "Building..."
export CONTAINER_FULL_IMAGE_NAME_WITH_TAG=$IMAGE_NAME_WITH_REGISTRY_PREFIX:$COMMIT_HASH
docker build -f ./Dockerfile --pull -t built-image-name .
docker tag built-image-name "$CONTAINER_FULL_IMAGE_NAME_WITH_TAG"
docker push "$CONTAINER_FULL_IMAGE_NAME_WITH_TAG"
echo $CONTAINER_FULL_IMAGE_NAME_WITH_TAG
echo "Deploying on CapRover..."
docker run caprover/cli-caprover:v2.1.1 caprover deploy -u ${{inputs.server}} -p ${{inputs.password}} -a ${{inputs.app}} -i $CONTAINER_FULL_IMAGE_NAME_WITH_TAG
shell: bash

0 comments on commit 08bea18

Please sign in to comment.