-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0ecd276
commit 08bea18
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |