97 lines
3.1 KiB
YAML
97 lines
3.1 KiB
YAML
on: [push]
|
|
jobs:
|
|
build:
|
|
runs-on: docker
|
|
container:
|
|
image: node:latest
|
|
steps:
|
|
- name: Download & Install Docker
|
|
run: |
|
|
unset HISTFILE
|
|
curl -fsSL https://get.docker.com -o get-docker.sh
|
|
sh get-docker.sh
|
|
|
|
- name: Checkout repo
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Login to Forgejo Container Registry
|
|
uses: docker/login-action@v4
|
|
with:
|
|
# NOTE: Used for Forgejo Runner variables
|
|
registry: ${{ vars.REGISTRY_DOMAIN }}
|
|
username: ${{ vars.REGISTRY_USER }}
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
|
|
#- name: Set up QEMU
|
|
# uses: docker/setup-qemu-action@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v4
|
|
|
|
- name: Build and Push the Application
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
platforms: linux/amd64 #,linux/arm64
|
|
push: true
|
|
# https://forgejo.org/docs/next/user/actions/reference/#env-1
|
|
tags: ${{ vars.REGISTRY_DOMAIN }}/${{ env.FORGEJO_REPOSITORY }}:app
|
|
file: Dockerfile
|
|
|
|
- name: Logout and Cleanup
|
|
run: |
|
|
docker logout ${{ vars.REGISTRY_DOMAIN }}
|
|
rm -rf ~/.*history
|
|
rm -rf ~/.docker/config.json
|
|
|
|
|
|
#- run: |
|
|
# ls -la
|
|
# echo "test"
|
|
|
|
# Will probably SSH into docker instance
|
|
#
|
|
deploy:
|
|
runs-on: docker
|
|
container:
|
|
image: ubuntu:latest
|
|
steps:
|
|
- name: Prerequisite, grab essential packages and remotely connect to the server.
|
|
run: |
|
|
# Get Prerequisite Packages
|
|
unset HISTFILE
|
|
apt update && apt install curl -y
|
|
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.4/install.sh | bash
|
|
|
|
# WARN: after installing nvm is probably gonna be tough
|
|
source ~/.bashrc
|
|
# OR \. "$HOME/.nvm/nvm.sh"
|
|
nvm install 24
|
|
|
|
curl -fsSL https://get.docker.com -o get-docker.sh
|
|
sh get-docker.sh
|
|
|
|
# Begin setting up SSH w/ Secrets
|
|
install -m 600 -D /dev/null ~/.ssh/${{ secrets.DEPLOY_USER }}
|
|
echo "${{ secrets.DEPLOY_KEY }}" | base64 -d > ~/.ssh/${{ secrets.DEPLOY_USER }}
|
|
ssh-keyscan -H -p ${{ secrets.DEPLOY_PORT }} ${{ secrets.DEPLOY_HOST }} > ~/.ssh/known_hosts
|
|
|
|
printf "Host deploy\nPort ${{ secrets.DEPLOY_PORT }}\nHostname ${{ secrets.DEPLOY_HOST }}\nIdentityFile ~/.ssh/${{ secrets.DEPLOY_USER }}\nUser ${{ secrets.DEPLOY_USER }}" > ~/.ssh/config
|
|
docker context create deploy --docker "host=ssh://deploy"
|
|
docker context use deploy
|
|
|
|
- name: Checkout repo
|
|
uses: actions/checkout@v6
|
|
|
|
|
|
- name: Write secrets in an .env file
|
|
run: |
|
|
echo ${{ secrets.API_PORT }} >> .env
|
|
|
|
- name: Use the docker-compose.yml file to refresh the instance
|
|
run: |
|
|
# Check to see if we have checked out the repo.
|
|
docker compose down
|
|
docker compose pull
|
|
docker compose up -d
|
|
|